Use optimisticRealpath when copying node_modules

This commit is contained in:
zodern
2019-12-23 10:31:03 -06:00
parent 8e8ea76289
commit d734481abd
3 changed files with 25 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ import {
readdir,
dependOnPath,
findAppDir,
realpath,
} from "./files";
// When in doubt, the optimistic caching system can be completely disabled
@@ -273,6 +274,24 @@ export const optimisticLStatOrNull = makeCheapPathFunction(
},
);
export const optimisticRealpath = makeOptimistic('realpath', realpath);
export const optimisticRealpathOrNull = makeOptimistic('realpathOrNull', (
path: string,
options?: Parameters<typeof optimisticRealpath>[1],
) => {
try {
return realpath(path, options)
} catch (e) {
if (e.code !== "ENOENT") {
throw e;
}
}
dependOnParentDirectory(path);
return null;
});
export const optimisticReadFile = makeOptimistic("readFile", readFile);
export const optimisticReaddir = makeOptimistic("readdir", readdir);
export const optimisticHashOrNull = makeOptimistic("hashOrNull", (

View File

@@ -11,6 +11,7 @@ import {
optimisticStatOrNull,
optimisticLStatOrNull,
optimisticHashOrNull,
optimisticRealpath,
} from "../fs/optimistic";
// Builder is in charge of writing "bundles" to disk, which are
@@ -540,7 +541,7 @@ Previous builder: ${previousBuilder.outputPath}, this builder: ${outputPath}`
// as well as node_modules/meteor and the parent directories of any
// scoped npm packages.
this._ensureAllNonPackageDirectories(
files.realpath(options.from),
optimisticRealpath(options.from),
options.to
);
}
@@ -637,7 +638,7 @@ Previous builder: ${previousBuilder.outputPath}, this builder: ${outputPath}`
});
}
const rootDir = files.realpath(from);
const rootDir = optimisticRealpath(from);
const walk = (absFrom, relTo) => {
if (symlink && ! (relTo in this.usedAsFile)) {
@@ -671,7 +672,7 @@ Previous builder: ${previousBuilder.outputPath}, this builder: ${outputPath}`
}
try {
var real = files.realpath(thisAbsFrom);
var real = optimisticRealpath(thisAbsFrom);
} catch (e) {
if (e.code !== "ENOENT" &&
e.code !== "ELOOP") {

View File

@@ -173,6 +173,7 @@ import { loadIsopackage } from '../tool-env/isopackets.js';
import { CORDOVA_PLATFORM_VERSIONS } from '../cordova';
import { gzipSync } from "zlib";
import { PackageRegistry } from "../../packages/meteor/define-package.js";
import { optimisticRealpathOrNull } from '../fs/optimistic';
const SOURCE_URL_PREFIX = "meteor://\u{1f4bb}app";
@@ -486,7 +487,7 @@ export class NodeModulesDirectory {
return true;
}
const real = files.realpathOrNull(path);
const real = optimisticRealpathOrNull(path);
if (typeof real === "string" &&
real !== path) {
// If node_modules/.bin/command is a symlink, determine the