Skip to content

Commit

Permalink
Make getFileIterator() return relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
rafeca committed Nov 2, 2018
1 parent 223c3db commit 635575c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
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 ([#XXX](https://github.com/facebook/jest/pull/XXX))

### 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

0 comments on commit 635575c

Please sign in to comment.