Skip to content

Commit

Permalink
Fixes things
Browse files Browse the repository at this point in the history
  • Loading branch information
Maël Nison committed Oct 2, 2018
1 parent 60f37bf commit 4f2b9f4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
15 changes: 9 additions & 6 deletions packages/jest-haste-map/src/crawlers/__tests__/watchman.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,24 @@ describe('watchman watch', () => {

return watchmanCrawl({
data: {
clocks: Object.create(null),
files: Object.create(null),
clocks: new Map(),
files: new Map(),
},
extensions: ['js', 'json', 'zip'],
ignore: pearMatcher,
mapper: n =>
n.endsWith('.zip')
? [path.join(n, 'foo.1.js'), path.join(n, 'foo.2.js')]
: null,
rootDir: ROOT_MOCK,
roots: ROOTS,
}).then(data => {
expect(data.files).toEqual({
[path.join(DURIAN_RELATIVE, 'foo.1.js')]: ['', 33, 0, [], null],
[path.join(DURIAN_RELATIVE, 'foo.2.js')]: ['', 33, 0, [], null],
});
expect(data.files).toEqual(
createMap({
[path.join(DURIAN_RELATIVE, 'foo.1.js')]: ['', 33, 0, [], null],
[path.join(DURIAN_RELATIVE, 'foo.2.js')]: ['', 33, 0, [], null],
}),
);
});
});

Expand Down
14 changes: 7 additions & 7 deletions packages/jest-haste-map/src/crawlers/watchman.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ module.exports = async function watchmanCrawl(
const existingFileData = data.files.get(relativeFilePath);
let nextData;

const isOld = existingFileData && existingFileData[H.MTIME] === mtime;
const hasChanged =
existingFileData && sha1hex && existingFileData[H.SHA1] === sha1hex;

if (existingFileData && isOld) {
if (existingFileData && existingFileData[H.MTIME] === mtime) {
nextData = existingFileData;
} else if (existingFileData && !hasChanged) {
} else if (
existingFileData &&
sha1hex &&
existingFileData[H.SHA1] === sha1hex
) {
nextData = [...existingFileData];
nextData[1] = mtime;
} else {
Expand All @@ -205,7 +205,7 @@ module.exports = async function watchmanCrawl(
if (!ignore(absoluteVirtualFilePath)) {
const relativeVirtualFilePath = fastPath.relative(
rootDir,
filePath,
absoluteVirtualFilePath,
);
files.set(relativeVirtualFilePath, nextData);
}
Expand Down

0 comments on commit 4f2b9f4

Please sign in to comment.