Skip to content

Commit 4f2b9f4

Browse files
author
Maël Nison
committed
Fixes things
1 parent 60f37bf commit 4f2b9f4

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

packages/jest-haste-map/src/crawlers/__tests__/watchman.test.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,21 +192,24 @@ describe('watchman watch', () => {
192192

193193
return watchmanCrawl({
194194
data: {
195-
clocks: Object.create(null),
196-
files: Object.create(null),
195+
clocks: new Map(),
196+
files: new Map(),
197197
},
198198
extensions: ['js', 'json', 'zip'],
199199
ignore: pearMatcher,
200200
mapper: n =>
201201
n.endsWith('.zip')
202202
? [path.join(n, 'foo.1.js'), path.join(n, 'foo.2.js')]
203203
: null,
204+
rootDir: ROOT_MOCK,
204205
roots: ROOTS,
205206
}).then(data => {
206-
expect(data.files).toEqual({
207-
[path.join(DURIAN_RELATIVE, 'foo.1.js')]: ['', 33, 0, [], null],
208-
[path.join(DURIAN_RELATIVE, 'foo.2.js')]: ['', 33, 0, [], null],
209-
});
207+
expect(data.files).toEqual(
208+
createMap({
209+
[path.join(DURIAN_RELATIVE, 'foo.1.js')]: ['', 33, 0, [], null],
210+
[path.join(DURIAN_RELATIVE, 'foo.2.js')]: ['', 33, 0, [], null],
211+
}),
212+
);
210213
});
211214
});
212215

packages/jest-haste-map/src/crawlers/watchman.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ module.exports = async function watchmanCrawl(
184184
const existingFileData = data.files.get(relativeFilePath);
185185
let nextData;
186186

187-
const isOld = existingFileData && existingFileData[H.MTIME] === mtime;
188-
const hasChanged =
189-
existingFileData && sha1hex && existingFileData[H.SHA1] === sha1hex;
190-
191-
if (existingFileData && isOld) {
187+
if (existingFileData && existingFileData[H.MTIME] === mtime) {
192188
nextData = existingFileData;
193-
} else if (existingFileData && !hasChanged) {
189+
} else if (
190+
existingFileData &&
191+
sha1hex &&
192+
existingFileData[H.SHA1] === sha1hex
193+
) {
194194
nextData = [...existingFileData];
195195
nextData[1] = mtime;
196196
} else {
@@ -205,7 +205,7 @@ module.exports = async function watchmanCrawl(
205205
if (!ignore(absoluteVirtualFilePath)) {
206206
const relativeVirtualFilePath = fastPath.relative(
207207
rootDir,
208-
filePath,
208+
absoluteVirtualFilePath,
209209
);
210210
files.set(relativeVirtualFilePath, nextData);
211211
}

0 commit comments

Comments
 (0)