Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit ee51b39

Browse files
chirag-shindeAlan Shaw
authored andcommitted
feat (cli): show error message if minimum node version isn't met (#2132)
* feat cli: show error if min node version isn't met - Added an error message display if the minimum node version requirement is not met. - Exits process with failure code 1. License: MIT Signed-off-by: Chirag Shinde <[email protected]> * fix(cli): show error if min node version isn't met - moved the version check to top before other `require` statements - changed `semver.gt` to `semver.satisfies` License: MIT Signed-off-by: Chirag Shinde <[email protected]>
1 parent 76689ff commit ee51b39

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
"pull-traverse": "^1.0.3",
187187
"readable-stream": "^3.1.1",
188188
"receptacle": "^1.3.2",
189+
"semver": "^6.1.1",
189190
"stream-to-pull-stream": "^1.7.3",
190191
"superstruct": "~0.6.0",
191192
"tar-stream": "^2.0.0",

src/cli/bin.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ process.on('unhandledRejection', (err) => {
1414
throw err
1515
})
1616

17+
const semver = require('semver')
18+
const pkg = require('../../package.json')
19+
20+
if (!semver.satisfies(process.versions.node, pkg.engines.node)) {
21+
console.error(`Please update your Node.js version to ${pkg.engines.node}`)
22+
process.exit(1)
23+
}
24+
1725
const YargsPromise = require('yargs-promise')
1826
const updateNotifier = require('update-notifier')
1927
const utils = require('./utils')
2028
const print = utils.print
2129
const mfs = require('ipfs-mfs/cli')
2230
const debug = require('debug')('ipfs:cli')
23-
const pkg = require('../../package.json')
2431
const parser = require('./parser')
2532
const commandAlias = require('./command-alias')
2633

0 commit comments

Comments
 (0)