Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
fix(commands): support prereleases of Node.js
Browse files Browse the repository at this point in the history
Prereleases of Node.js such as nightly or canary releases have a
prerelease tag. Their version strings are valid semver but
semver.satisfies does not return true when compared to a regular version
number.

Refs: https://www.npmjs.com/package/semver#prerelease-tags
  • Loading branch information
targos committed Jul 31, 2018
1 parent f6ec54c commit 4525cc5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Services/check-node-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

const semver = require('semver')
const requiredNodeVersion = '>=8.0.0'
const requiredNodeVersionNumber = 8
const requiredNpmVersion = '>=3.0.0'

/**
Expand All @@ -32,9 +33,11 @@ module.exports = async function (stepsCounter) {

/**
* Verify Node.js version
* Uses `semver.parse` instead of `semver.satistfies` to support prereleases
* of Node.js
*/
const nodeVersion = process.version
if (!semver.satisfies(nodeVersion, requiredNodeVersion)) {
if (semver.parse(nodeVersion).major < requiredNodeVersionNumber) {
step.error('Unsupported Node.js version', 'x')
throw new Error(`Unsatisfied Node.js version ${nodeVersion}. Please update Node.js to ${requiredNodeVersion} before you continue`)
}
Expand Down

0 comments on commit 4525cc5

Please sign in to comment.