Skip to content

Commit

Permalink
WIP: add --default-command config
Browse files Browse the repository at this point in the history
Implementation spike for npm/rfcs#279
  • Loading branch information
isaacs committed Nov 9, 2020
1 parent 8fa541a commit 136380b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/cli.js
Expand Up @@ -56,8 +56,9 @@ module.exports = (process) => {
impl(npm.argv, errorHandler)
else {
npm.config.set('usage', false)
npm.argv.unshift(cmd)
npm.commands.help(npm.argv, errorHandler)
if (cmd !== undefined)
npm.argv.unshift(cmd)
npm.commands[npm.config.get('default-command')](npm.argv, errorHandler)
}
})
}
4 changes: 4 additions & 0 deletions lib/utils/config.js
Expand Up @@ -70,6 +70,7 @@ const defaults = {
cidr: null,
color: process.env.NO_COLOR == null,
'commit-hooks': true,
'default-command': 'help',
depth: null,
description: true,
dev: false,
Expand Down Expand Up @@ -186,6 +187,8 @@ const defaults = {
viewer: isWindows ? 'browser' : 'man',
}

const { cmdList } = require('./cmd-list.js')

const types = {
access: [null, 'restricted', 'public'],
all: Boolean,
Expand All @@ -212,6 +215,7 @@ const types = {
cidr: [null, String, Array],
color: ['always', Boolean],
'commit-hooks': Boolean,
'default-command': cmdList,
depth: [null, Number],
description: Boolean,
dev: Boolean,
Expand Down

0 comments on commit 136380b

Please sign in to comment.