-
Notifications
You must be signed in to change notification settings - Fork 3k
Suggest similar commands when run command isn't found #20741
Description
I'm opening this issue because:
- npm is crashing.
- npm is producing an incorrect install.
- npm is doing something I don't understand.
- npm is producing incorrect or undesirable behavior.
- Other (see below for feature requests):
What's the feature?
Unlike other packages such as Git, if you mistype a command, there is no suggestion of similar commands you might have meant.
What problem is the feature intended to solve?
Suppose the user has a script lint:src and tries these commands:
src:tslint❌src:lint❌tslint:src❌lint:srv❌lint:src✔
None of the ❌s give an indication of other commands being similar.
C:\Code\Project (master -> origin)
λ npm run src:lint
npm ERR! missing script: src:lint
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jogol\AppData\Roaming\npm-cache\_logs\2018-05-24T10_40_07_124Z-debug.log
Easy mode: tslint:src❌ and lint:srv❌ have low edit distances to lint:src✔. Solution proposal: if the command isn't found, give the first 1-3 commands with a low edit distance out of the union of (built in commands) & (package.json commands).
Hard mode: src:lint❌ flips lint:src✔ around the :. How common is the group:specific pattern? It could be useful to also check reverses of the scripts and consider them in the edit distances.
Bonus points if someone puts the 📎 emoji and "I see you're trying to X" phrasing in there on terminals that can support it!
C:\Code\Project (master -> origin)
λ npm run src:lint
npm ERR! missing script: src:lint
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jogol\AppData\Roaming\npm-cache\_logs\2018-05-24T10_40_07_124Z-debug.log
📎 I see you're trying to run a command! Did you mean to type:
npm run lint:src
Is the absence of this feature blocking you or your team? If so, how?
Not a blocker. However, for devs on my team who are either new to programming in general or come from the non-JS areas, this is an infrequent complaint.
Is this feature similar to an existing feature in another tool?
Git:
λ git pust
git: 'pust' is not a git command. See 'git --help'.
The most similar command is
push
Is this a feature you're prepared to implement, with support from the npm CLI team?
Heck yes! 🤘