Skip to content

Commit

Permalink
use realpath-native
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Oct 21, 2018
1 parent 8d51463 commit 9c29b39
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/jest-haste-map/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"jest-serializer": "^23.0.1",
"jest-worker": "^23.2.0",
"micromatch": "^2.3.11",
"realpath-native": "^1.0.0",
"sane": "^3.0.0"
}
}
2 changes: 2 additions & 0 deletions packages/jest-haste-map/src/crawlers/watchman.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ module.exports = async function watchmanCrawl(
if (existingFileData && existingFileData[H.MTIME] === mtime) {
cache.set(fileName, existingFileData);
} else if (fileData.type !== 'f') {
// See ../constants.js
cache.set(fileName, [undefined, mtime]);
} else if (
sha1hex &&
Expand All @@ -224,6 +225,7 @@ module.exports = async function watchmanCrawl(
existingFileData[4],
]);
} else {
// See ../constants.js
cache.set(fileName, ['', mtime, 0, [], sha1hex]);
}
}
Expand Down
10 changes: 8 additions & 2 deletions packages/jest-haste-map/src/haste_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import type {Glob, Path} from 'types/Config';
import type {FileData, LinkData} from 'types/HasteMap';

import * as fastPath from './lib/fast_path';
import fs from 'fs';
import micromatch from 'micromatch';
import {sync as realpath} from 'realpath-native';
import H from './constants';

export default class HasteFS {
Expand Down Expand Up @@ -55,7 +55,13 @@ export default class HasteFS {

follow(file: Path): Path {
const link = this._links[file];
return link ? link[0] || (link[0] = fs.realpathSync(file)) : file;
if (link === undefined) {
return file;
}
if (link[0] === undefined) {
link[0] = realpath(file);
}
return link[0];
}

getAllFiles(): Array<string> {
Expand Down

0 comments on commit 9c29b39

Please sign in to comment.