check-node-version
Advanced tools
Comparing version 4.0.3 to 4.1.0
43
cli.js
@@ -22,2 +22,4 @@ "use strict"; | ||
"help", | ||
"volta", | ||
"package", | ||
], | ||
@@ -29,3 +31,7 @@ string: [ | ||
"yarn", | ||
] | ||
], | ||
unknown: function (arg) { | ||
console.error(`Unknown option: ${arg}`); | ||
process.exit(1); | ||
} | ||
}); | ||
@@ -42,5 +48,11 @@ | ||
let options; | ||
if (argv.package) { | ||
options = optionsFromPackage(); | ||
} else if (argv.volta) { | ||
options = optionsFromVolta(); | ||
} else { | ||
options = optionsFromCommandLine(); | ||
} | ||
const options = argv.package ? optionsFromPackage() : optionsFromCommandLine(); | ||
check(options, (err, result) => { | ||
@@ -91,3 +103,28 @@ if (err) { | ||
function optionsFromVolta() { | ||
let packageJson; | ||
try { | ||
packageJson = require(path.join(process.cwd(), 'package.json')); | ||
} catch (e) { | ||
console.log('Error: When running with --volta, a package.json file is expected in the current working directory'); | ||
console.log('Current working directory is: ' + process.cwd()); | ||
process.exit(1); | ||
} | ||
if (!packageJson.volta) { | ||
console.log('Error: When running with --volta, your package.json is expected to contain the "volta" key'); | ||
console.log('See https://docs.volta.sh/guide/understanding#pinning-node-engines'); | ||
process.exit(1); | ||
} | ||
console.log(packageJson.volta); | ||
return Object.keys(tools).reduce((memo, name) => ({ | ||
...memo, | ||
[name]: packageJson.volta[name], | ||
}), {}); | ||
} | ||
// | ||
@@ -94,0 +131,0 @@ |
{ | ||
"name": "check-node-version", | ||
"version": "4.0.3", | ||
"version": "4.1.0", | ||
"engines": { | ||
@@ -49,3 +49,3 @@ "node": ">=8.3.0" | ||
"husky": "^3.1.0", | ||
"npm": "6.13.4", | ||
"npm": "6.14.6", | ||
"npm-run-all": "^4.1.5", | ||
@@ -52,0 +52,0 @@ "proxyquire": "^2.1.3" |
@@ -5,3 +5,3 @@ <a name="check-node-version"></a> | ||
[![AppVeyor build status](https://img.shields.io/appveyor/ci/parshap/check-node-version/master.svg?style=flat-square)](https://ci.appveyor.com/project/parshap/check-node-version/branch/master) | ||
[![Travis build status](http://img.shields.io/travis/parshap/check-node-version/master.svg?style=flat-square)](https://travis-ci.org/parshap/check-node-version) | ||
[![Travis build status](http://img.shields.io/travis/parshap/check-node-version/master.svg?style=flat-square)](https://travis-ci.org/samsaggace/check-node-version) | ||
@@ -62,2 +62,5 @@ Check installed versions of `node`, `npm`, `npx`, and `yarn`. | ||
semver version ranges. | ||
--volta | ||
Use the versions pinned by Volta in the package.json | ||
@@ -110,2 +113,11 @@ -p, --print | ||
<a name="check-node-version-command-line-usage-examples-check-for-volta-pinned-versions"></a> | ||
#### Check for volta pinned versions | ||
You can check versions pinned by [Volta](https://volta.sh/): | ||
```bash | ||
$ check-node-version --volta | ||
``` | ||
<a name="check-node-version-command-line-usage-examples-print-installed-versions"></a> | ||
@@ -112,0 +124,0 @@ #### Print installed versions |
@@ -33,2 +33,5 @@ SYNOPSIS | ||
semver version ranges. | ||
--volta | ||
Use the versions pinned by Volta in the package.json | ||
@@ -35,0 +38,0 @@ -p, --print |
24940
503
218
6