Skip to content

Commit

Permalink
Improve abbrevs for install and help
Browse files Browse the repository at this point in the history
The existence of 'install-test' and 'install-clean' make 'npm inst' no longer
de-reference to 'npm install'.  Similarly, the existence of 'help-search'
prevents 'hel' from being a shorthand for 'help'.

This adds some artisanally hand-crafted abbreviations for these cases.

Fix: #1617

PR-URL: #1622
Credit: @isaacs
Close: #1622
Reviewed-by: @ruyadorno
  • Loading branch information
isaacs authored and ruyadorno committed Aug 6, 2020
1 parent 0d9b127 commit cf28192
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
15 changes: 11 additions & 4 deletions lib/config/cmd-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ const affordances = {
verison: 'version',
ic: 'ci',
innit: 'init',
isntall: 'install',
// manually abbrev so that install-test doesn't make insta stop working
in: 'install',
ins: 'install',
inst: 'install',
insta: 'install',
instal: 'install',
isnt: 'install',
isnta: 'install',
isntal: 'install',
'install-clean': 'ci',
'isntall-clean': 'ci',
hlep: 'help',
'dist-tags': 'dist-tag',
apihelp: 'help',
upgrade: 'update',
udpate: 'update',
login: 'adduser',
Expand Down Expand Up @@ -95,7 +103,6 @@ const cmdList = [
'org',

'help',
'help-search',
'ls',
'll',
'search',
Expand Down Expand Up @@ -124,7 +131,7 @@ const cmdList = [
'exec'
]

const plumbing = ['birthday']
const plumbing = ['birthday', 'help-search']
module.exports = {
aliases: Object.assign({}, shorthands, affordances),
shorthands,
Expand Down
24 changes: 19 additions & 5 deletions tap-snapshots/test-lib-config-cmd-list.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ Object {
"affordances": Object {
"add": "install",
"add-user": "adduser",
"apihelp": "help",
"author": "owner",
"dist-tags": "dist-tag",
"find": "search",
"hlep": "help",
"home": "docs",
"ic": "ci",
"in": "install",
"info": "view",
"innit": "init",
"ins": "install",
"inst": "install",
"insta": "install",
"instal": "install",
"install-clean": "ci",
"isntall": "install",
"isnt": "install",
"isnta": "install",
"isntal": "install",
"isntall-clean": "ci",
"issues": "bugs",
"la": "ll",
Expand All @@ -40,7 +47,6 @@ Object {
"aliases": Object {
"add": "install",
"add-user": "adduser",
"apihelp": "help",
"author": "owner",
"c": "config",
"cit": "install-ci-test",
Expand All @@ -50,13 +56,21 @@ Object {
"ddp": "dedupe",
"dist-tags": "dist-tag",
"find": "search",
"hlep": "help",
"home": "docs",
"i": "install",
"ic": "ci",
"in": "install",
"info": "view",
"innit": "init",
"ins": "install",
"inst": "install",
"insta": "install",
"instal": "install",
"install-clean": "ci",
"isntall": "install",
"isnt": "install",
"isnta": "install",
"isntal": "install",
"isntall-clean": "ci",
"issues": "bugs",
"it": "install-test",
Expand Down Expand Up @@ -125,7 +139,6 @@ Object {
"fund",
"org",
"help",
"help-search",
"ls",
"ll",
"search",
Expand Down Expand Up @@ -154,6 +167,7 @@ Object {
],
"plumbing": Array [
"birthday",
"help-search",
],
"shorthands": Object {
"c": "config",
Expand Down
24 changes: 12 additions & 12 deletions tap-snapshots/test-lib-utils-update-notifier.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,73 @@
*/
'use strict'
exports[`test/lib/utils/update-notifier.js TAP notification situations color and unicode major > must match snapshot 1`] = `
New [31mmajor[39m version of npm available! [31m<<major>>-beta.0[39m → [32m7.0.0[39m
New [31mmajor[39m version of npm available! [31m<<major>>-beta.1[39m → [32m7.0.0[39m
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm install -g npm to update!
`

exports[`test/lib/utils/update-notifier.js TAP notification situations color and unicode minor > must match snapshot 1`] = `
New [33mminor[39m version of npm available! [31m<<minor>>-beta.0[39m → [32m7.0.0[39m
New [33mminor[39m version of npm available! [31m<<minor>>-beta.1[39m → [32m7.0.0[39m
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm install -g npm to update!
`

exports[`test/lib/utils/update-notifier.js TAP notification situations color and unicode minor > must match snapshot 2`] = `
New [32mpatch[39m version of npm available! [31m<<patch>>-beta.0[39m → [32m7.0.0[39m
New [32mpatch[39m version of npm available! [31m<<patch>>-beta.1[39m → [32m7.0.0[39m
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm install -g npm to update!
`

exports[`test/lib/utils/update-notifier.js TAP notification situations color, no unicode major > must match snapshot 1`] = `
New [31mmajor[39m version of npm available! [31m<<major>>-beta.0[39m -> [32m7.0.0[39m
New [31mmajor[39m version of npm available! [31m<<major>>-beta.1[39m -> [32m7.0.0[39m
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm install -g npm to update!
`

exports[`test/lib/utils/update-notifier.js TAP notification situations color, no unicode minor > must match snapshot 1`] = `
New [33mminor[39m version of npm available! [31m<<minor>>-beta.0[39m -> [32m7.0.0[39m
New [33mminor[39m version of npm available! [31m<<minor>>-beta.1[39m -> [32m7.0.0[39m
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm install -g npm to update!
`

exports[`test/lib/utils/update-notifier.js TAP notification situations color, no unicode minor > must match snapshot 2`] = `
New [32mpatch[39m version of npm available! [31m<<patch>>-beta.0[39m -> [32m7.0.0[39m
New [32mpatch[39m version of npm available! [31m<<patch>>-beta.1[39m -> [32m7.0.0[39m
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm install -g npm to update!
`

exports[`test/lib/utils/update-notifier.js TAP notification situations no color, no unicode major > must match snapshot 1`] = `
New major version of npm available! <<major>>-beta.0 -> 7.0.0
New major version of npm available! <<major>>-beta.1 -> 7.0.0
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm i -g npm to update!
`

exports[`test/lib/utils/update-notifier.js TAP notification situations no color, no unicode minor > must match snapshot 1`] = `
New minor version of npm available! <<minor>>-beta.0 -> 7.0.0
New minor version of npm available! <<minor>>-beta.1 -> 7.0.0
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm i -g npm to update!
`

exports[`test/lib/utils/update-notifier.js TAP notification situations no color, no unicode minor > must match snapshot 2`] = `
New patch version of npm available! <<patch>>-beta.0 -> 7.0.0
New patch version of npm available! <<patch>>-beta.1 -> 7.0.0
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm i -g npm to update!
`

exports[`test/lib/utils/update-notifier.js TAP notification situations unicode, no color major > must match snapshot 1`] = `
New major version of npm available! <<major>>-beta.0 → 7.0.0
New major version of npm available! <<major>>-beta.1 → 7.0.0
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm i -g npm to update!
`

exports[`test/lib/utils/update-notifier.js TAP notification situations unicode, no color minor > must match snapshot 1`] = `
New minor version of npm available! <<minor>>-beta.0 → 7.0.0
New minor version of npm available! <<minor>>-beta.1 → 7.0.0
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm i -g npm to update!
`

exports[`test/lib/utils/update-notifier.js TAP notification situations unicode, no color minor > must match snapshot 2`] = `
New patch version of npm available! <<patch>>-beta.0 → 7.0.0
New patch version of npm available! <<patch>>-beta.1 → 7.0.0
Changelog: https://github.com/npm/cli/releases/tag/v7.0.0
Run npm i -g npm to update!
`
2 changes: 1 addition & 1 deletion tap-snapshots/test-lib-view.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ dist
dist-tags:
published [33m12 months ago[39m
published [33ma year ago[39m
`

exports[`test/lib/view.js TAP should log package info package with no versions > must match snapshot 1`] = `
Expand Down

0 comments on commit cf28192

Please sign in to comment.