diff options
Diffstat (limited to 'deps/npm/node_modules/libnpmexec/lib/index.js')
-rw-r--r-- | deps/npm/node_modules/libnpmexec/lib/index.js | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/deps/npm/node_modules/libnpmexec/lib/index.js b/deps/npm/node_modules/libnpmexec/lib/index.js index 906a0b5407c..a48c654bf6a 100644 --- a/deps/npm/node_modules/libnpmexec/lib/index.js +++ b/deps/npm/node_modules/libnpmexec/lib/index.js @@ -1,7 +1,6 @@ -const { delimiter, resolve } = require('path') +const { delimiter, dirname, resolve } = require('path') const { promisify } = require('util') const read = promisify(require('read')) -const stat = promisify(require('fs').stat) const Arborist = require('@npmcli/arborist') const ciDetect = require('@npmcli/ci-detect') @@ -12,15 +11,12 @@ const pacote = require('pacote') const readPackageJson = require('read-package-json-fast') const cacheInstallDir = require('./cache-install-dir.js') +const { fileExists, localFileExists } = require('./file-exists.js') const getBinFromManifest = require('./get-bin-from-manifest.js') const manifestMissing = require('./manifest-missing.js') const noTTY = require('./no-tty.js') const runScript = require('./run-script.js') -const fileExists = (file) => stat(file) - .then((stat) => stat.isFile()) - .catch(() => false) - /* istanbul ignore next */ const PATH = ( process.env.PATH || process.env.Path || process.env.path @@ -31,7 +27,7 @@ const exec = async (opts) => { args = [], call = '', color = false, - localBin = '', + localBin = resolve('./node_modules/.bin'), locationMsg = undefined, globalBin = '', output, @@ -72,8 +68,10 @@ const exec = async (opts) => { // the behavior of treating the single argument as a package name if (needPackageCommandSwap) { let binExists = false - if (await fileExists(`${localBin}/${args[0]}`)) { - pathArr.unshift(localBin) + const dir = dirname(dirname(localBin)) + const localBinPath = await localFileExists(dir, args[0]) + if (localBinPath) { + pathArr.unshift(localBinPath) binExists = true } else if (await fileExists(`${globalBin}/${args[0]}`)) { pathArr.unshift(globalBin) @@ -145,7 +143,7 @@ const exec = async (opts) => { }, })) .map(mani => mani._from) - .sort((a, b) => a.localeCompare(b)) + .sort((a, b) => a.localeCompare(b, 'en')) // no need to install if already present if (add.length) { |