add new -S / --success-on-unchanged argument for conditional update
This commit is contained in:
parent
61a6d43ce4
commit
da8f0cdac8
10
README.md
10
README.md
@ -24,6 +24,11 @@ When changes are satisfactory, update `package.json` and re-install modules:
|
||||
$ npx updates -u && rm -rf node_modules && npm i
|
||||
```
|
||||
|
||||
To conditionally reinstall modules only when updates are available:
|
||||
```console
|
||||
$ npx updates -S -u && rm -rf node_modules && npm i
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
See `--help` or below for the available options. Option that take multiple arguments can take them either via comma-separated value or by specifying the option multiple times. If an option has a optional `pkg` argument but none is given, the option will be applied to all packages instead.
|
||||
@ -41,8 +46,9 @@ usage: updates [options]
|
||||
-t, --types <type,...> Check only given dependency types
|
||||
-P, --patch [<pkg,...>] Consider only up to semver-patch
|
||||
-m, --minor [<pkg,...>] Consider only up to semver-minor
|
||||
-E, --error-on-outdated Exit with error code 2 on outdated packages
|
||||
-r, --registry <url> Use given registry URL
|
||||
-E, --error-on-outdated Exit with code 2 when updates are available and code 0 when not
|
||||
-S, --success-on-unchanged Exit with code 0 when updates are available and code 2 when not
|
||||
-r, --registry <url> Override npm registry URL
|
||||
-f, --file <path> Use given package.json file or module directory
|
||||
-j, --json Output a JSON object
|
||||
-c, --color Force-enable color output
|
||||
|
@ -7,6 +7,7 @@ const args = require("minimist")(process.argv.slice(2), {
|
||||
boolean: [
|
||||
"c", "color",
|
||||
"E", "error-on-outdated",
|
||||
"S", "success-on-unchanged",
|
||||
"h", "help",
|
||||
"j", "json",
|
||||
"n", "no-color",
|
||||
@ -26,6 +27,7 @@ const args = require("minimist")(process.argv.slice(2), {
|
||||
alias: {
|
||||
c: "color",
|
||||
E: "error-on-outdated",
|
||||
S: "success-on-unchanged",
|
||||
e: "exclude",
|
||||
f: "file",
|
||||
g: "greatest",
|
||||
@ -58,7 +60,8 @@ if (args.help) {
|
||||
-t, --types <type,...> Check only given dependency types
|
||||
-P, --patch [<pkg,...>] Consider only up to semver-patch
|
||||
-m, --minor [<pkg,...>] Consider only up to semver-minor
|
||||
-E, --error-on-outdated Exit with error code 2 on outdated packages
|
||||
-E, --error-on-outdated Exit with code 2 when updates are available and code 0 when not
|
||||
-S, --success-on-unchanged Exit with code 0 when updates are available and code 2 when not
|
||||
-r, --registry <url> Override npm registry URL
|
||||
-f, --file <path> Use given package.json file or module directory
|
||||
-j, --json Output a JSON object
|
||||
@ -350,6 +353,8 @@ function finish(obj, opts = {}) {
|
||||
|
||||
if (args["error-on-outdated"]) {
|
||||
process.exit(Object.keys(deps).length ? 2 : 0);
|
||||
} else if (args["success-on-unchanged"]) {
|
||||
process.exit(Object.keys(deps).length ? 0 : 2);
|
||||
} else {
|
||||
process.exit(opts.exitCode || (output.error ? 1 : 0));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user