From 365ceb638662abbbd642ebbc0f47760e8d9dc2ce Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Wed, 8 Feb 2017 17:18:30 -0500 Subject: [PATCH] Tolerate ENOENT exceptions from files.realpath in isWithinProdPackage. --- tools/isobuild/bundler.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/isobuild/bundler.js b/tools/isobuild/bundler.js index f84c95b8c3..5493510c5b 100644 --- a/tools/isobuild/bundler.js +++ b/tools/isobuild/bundler.js @@ -482,8 +482,9 @@ export class NodeModulesDirectory { return true; } - const real = files.realpath(path); - if (real !== path) { + const real = realpathOrNull(path); + if (typeof real === "string" && + real !== path) { // If node_modules/.bin/command is a symlink, determine the // answer by calling isWithinProdPackage(real). return isWithinProdPackage(real); @@ -521,6 +522,15 @@ export class NodeModulesDirectory { } } +function realpathOrNull(path) { + try { + return files.realpath(path); + } catch (e) { + if (e.code !== "ENOENT") throw e; + return null; + } +} + /////////////////////////////////////////////////////////////////////////////// // File ///////////////////////////////////////////////////////////////////////////////