Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/utils/did-you-mean.js')
-rw-r--r--deps/npm/lib/utils/did-you-mean.js8
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]