Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make getFileIterator() return relative paths #7321

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- `[expect]` Check constructor equality in .toStrictEqual() ([#7005](https://github.com/facebook/jest/pull/7005))
- `[jest-util]` Add `jest.getTimerCount()` to get the count of scheduled fake timers ([#7285](https://github.com/facebook/jest/pull/7285))
- `[jest-config]` Add `dependencyExtractor` option to use a custom module to extract dependencies from files ([#7313](https://github.com/facebook/jest/pull/7313))
- `[jest-haste-map]` [**BREAKING**] Expose relative paths when getting the file iterator ([#7321](https://github.com/facebook/jest/pull/7321))

### Fixes

Expand Down
12 changes: 8 additions & 4 deletions packages/jest-haste-map/src/HasteFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ export default class HasteFS {
}

getAllFiles(): Array<string> {
return Array.from(this.getFileIterator());
return Array.from(this.getAbsoluteFileIterator());
}

*getFileIterator(): Iterator<string> {
getFileIterator(): Iterator<string> {
return this._files.keys();
}

*getAbsoluteFileIterator(): Iterator<string> {
for (const file of this._files.keys()) {
yield fastPath.resolve(this._rootDir, file);
}
Expand All @@ -57,7 +61,7 @@ export default class HasteFS {
pattern = new RegExp(pattern);
}
const files = [];
for (const file of this.getFileIterator()) {
for (const file of this.getAbsoluteFileIterator()) {
if (pattern.test(file)) {
files.push(file);
}
Expand All @@ -67,7 +71,7 @@ export default class HasteFS {

matchFilesWithGlob(globs: Array<Glob>, root: ?Path): Set<Path> {
const files = new Set();
for (const file of this.getFileIterator()) {
for (const file of this.getAbsoluteFileIterator()) {
const filePath = root ? fastPath.relative(root, file) : file;
if (micromatch([filePath], globs).length) {
files.add(file);
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-resolve-dependencies/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class DependencyResolver {
}
}
const modules = [];
for (const file of this._hasteFS.getFileIterator()) {
for (const file of this._hasteFS.getAbsoluteFileIterator()) {
modules.push({
dependencies: this.resolve(file, options),
file,
Expand Down