From 9c29b397553dba24fbc82ba5b847315ed2beaca0 Mon Sep 17 00:00:00 2001 From: aleclarson Date: Wed, 19 Sep 2018 09:45:01 -0400 Subject: [PATCH] use realpath-native --- packages/jest-haste-map/package.json | 1 + packages/jest-haste-map/src/crawlers/watchman.js | 2 ++ packages/jest-haste-map/src/haste_fs.js | 10 ++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/jest-haste-map/package.json b/packages/jest-haste-map/package.json index b0e5089cf015..2437c738a0a4 100644 --- a/packages/jest-haste-map/package.json +++ b/packages/jest-haste-map/package.json @@ -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" } } diff --git a/packages/jest-haste-map/src/crawlers/watchman.js b/packages/jest-haste-map/src/crawlers/watchman.js index 5c633ab53241..4e17672f547a 100644 --- a/packages/jest-haste-map/src/crawlers/watchman.js +++ b/packages/jest-haste-map/src/crawlers/watchman.js @@ -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 && @@ -224,6 +225,7 @@ module.exports = async function watchmanCrawl( existingFileData[4], ]); } else { + // See ../constants.js cache.set(fileName, ['', mtime, 0, [], sha1hex]); } } diff --git a/packages/jest-haste-map/src/haste_fs.js b/packages/jest-haste-map/src/haste_fs.js index 8e0d0581e49c..beade8e31e95 100644 --- a/packages/jest-haste-map/src/haste_fs.js +++ b/packages/jest-haste-map/src/haste_fs.js @@ -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 { @@ -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 {