Skip to content

Commit a05de1d

Browse files
committed
use realpath-native
1 parent 10b7c9b commit a05de1d

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

packages/jest-haste-map/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"jest-serializer": "^23.0.1",
1616
"jest-worker": "^23.2.0",
1717
"micromatch": "^2.3.11",
18+
"realpath-native": "^1.0.0",
1819
"sane": "^2.0.0"
1920
}
2021
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ module.exports = async function watchmanCrawl(
200200
if (existingMetaData && existingMetaData[H.MTIME] === mtime) {
201201
cache.set(name, existingMetaData);
202202
} else if (fileData.type !== 'f') {
203+
// See ../constants.js
203204
cache.set(name, [undefined, mtime]);
204205
} else if (
205206
existingMetaData &&
@@ -214,6 +215,7 @@ module.exports = async function watchmanCrawl(
214215
existingMetaData[4],
215216
]);
216217
} else {
218+
// See ../constants.js
217219
cache.set(name, ['', mtime, 0, [], sha1hex]);
218220
}
219221
}

packages/jest-haste-map/src/haste_fs.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import type {Glob, Path} from 'types/Config';
1111
import type {FileData, LinkData} from 'types/HasteMap';
1212

13-
import fs from 'fs';
1413
import path from 'path';
1514
import micromatch from 'micromatch';
15+
import {sync as realpath} from 'realpath-native';
1616
import H from './constants';
1717

1818
export default class HasteFS {
@@ -45,7 +45,13 @@ export default class HasteFS {
4545

4646
follow(file: Path): Path {
4747
const link = this._links[file];
48-
return link ? link[0] || (link[0] = fs.realpathSync(file)) : file;
48+
if (link === undefined) {
49+
return file;
50+
}
51+
if (link[0] === undefined) {
52+
link[0] = realpath(file);
53+
}
54+
return link[0];
4955
}
5056

5157
getAllFiles(): Array<string> {

0 commit comments

Comments
 (0)