diff options
author | npm team <ops+robot@npmjs.com> | 2021-08-19 20:47:33 +0300 |
---|---|---|
committer | Luigi Pinca <luigipinca@gmail.com> | 2021-08-20 15:53:49 +0300 |
commit | 248f4c376444d0202f1d08f039c59485d6aea2e9 (patch) | |
tree | 270bcf6dd5734fa43ea1603bfc4a066b6f8f7926 /deps/npm/lib/utils/did-you-mean.js | |
parent | 279162cf98b22ec5d0afc182ea22c7a782ccd083 (diff) |
deps: upgrade npm to 7.21.0
PR-URL: https://github.com/nodejs/node/pull/39813
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'deps/npm/lib/utils/did-you-mean.js')
-rw-r--r-- | deps/npm/lib/utils/did-you-mean.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/deps/npm/lib/utils/did-you-mean.js b/deps/npm/lib/utils/did-you-mean.js index 98133196e3c..0cfdd035255 100644 --- a/deps/npm/lib/utils/did-you-mean.js +++ b/deps/npm/lib/utils/did-you-mean.js @@ -1,10 +1,10 @@ -const leven = require('leven') +const { distance } = require('fastest-levenshtein') const readJson = require('read-package-json-fast') const { cmdList } = require('./cmd-list.js') const didYouMean = async (npm, path, scmd) => { const bestCmd = cmdList - .filter(cmd => leven(scmd, cmd) < scmd.length * 0.4 && scmd !== cmd) + .filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 && scmd !== cmd) .map(str => ` npm ${str} # ${npm.commands[str].description}`) const pkg = await readJson(`${path}/package.json`) @@ -12,13 +12,13 @@ const didYouMean = async (npm, path, scmd) => { // We would already be suggesting this in `npm x` so omit them here const runScripts = ['stop', 'start', 'test', 'restart'] const bestRun = Object.keys(scripts || {}) - .filter(cmd => leven(scmd, cmd) < scmd.length * 0.4 && + .filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 && !runScripts.includes(cmd)) .map(str => ` npm run ${str} # run the "${str}" package script`) const { bin } = pkg const bestBin = Object.keys(bin || {}) - .filter(cmd => leven(scmd, cmd) < scmd.length * 0.4) + .filter(cmd => distance(scmd, cmd) < scmd.length * 0.4) .map(str => ` npm exec ${str} # run the "${str}" command from either this or a remote npm package`) const best = [...bestCmd, ...bestRun, ...bestBin] |