Skip to content

Commit

Permalink
Upgrade during interactive mode by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Nov 24, 2019
1 parent ec85d80 commit 7578264
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ Options
-f, --filter include only package names matching the given string,
comma-or-space-delimited list, or /regex/
-g, --global check global packages instead of in the current project
-i, --interactive Enable interactive prompts for each dependency
-i, --interactive Enable interactive prompts for each dependency;
Implies -u unless one of the json options are set
-j, --jsonAll output new package file instead of human-readable
message
--jsonDeps Will return output like `jsonAll` but only lists
Expand Down
2 changes: 1 addition & 1 deletion bin/ncu
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ program
.option('-f, --filter <matches>', 'include only package names matching the given string, comma-or-space-delimited list, or /regex/')
.option('-g, --global', 'check global packages instead of in the current project')
// program.json is set to true in programInit if any options that begin with 'json' are true
.option('-i, --interactive', 'Enable interactive prompts for each dependency')
.option('-i, --interactive', 'Enable interactive prompts for each dependency; implies -u unless one of the json options are set')
.option('-j, --jsonAll', 'output new package file instead of human-readable message')
.option('--jsonDeps', 'Will return output like `jsonAll` but only lists `dependencies`, `devDependencies`, and `optionalDependencies` of the new package data.')
.option('--jsonUpgraded', 'output upgraded dependencies in json')
Expand Down
12 changes: 8 additions & 4 deletions lib/npm-check-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ function printUpgrades(options, {current, upgraded, numUpgraded, total}) {
/** Initializes and consolidates options from the cli. */
function initOptions(options) {

const json = _(options)
.keys()
.filter(_.partial(_.startsWith, _, 'json', 0))
.some(_.propertyOf(options));

return Object.assign({}, options, {
filter: options.args.join(' ') || options.filter,
// convert silent option to loglevel silent
Expand All @@ -303,10 +308,9 @@ function initOptions(options) {
// default to 0, except when newest or greatest are set
pre: options.pre ? Boolean(Number(options.pre)) : options.newest || options.greatest,
// add shortcut for any keys that start with 'json'
json: _(options)
.keys()
.filter(_.partial(_.startsWith, _, 'json', 0))
.some(_.propertyOf(options))
json,
// imply upgrade in interactive mode when json is not specified as the output
upgrade: options.interactive && options.upgrade === undefined ? !json : options.upgrade
});
}

Expand Down

0 comments on commit 7578264

Please sign in to comment.