MDL-55856 grunt: fail gracefully when node version too old

Unfortunately the engine requirement in packages.json is not a fatal
error, so you can get unhelpful errors with grunt if using an
unsupported version.
This commit is contained in:
Dan Poltawski 2016-09-05 14:54:01 +01:00
parent 1f2744851f
commit d2c7175a34
3 changed files with 479 additions and 470 deletions

View File

@ -30,7 +30,15 @@ module.exports = function(grunt) {
cwd = process.env.PWD || process.cwd(),
async = require('async'),
DOMParser = require('xmldom').DOMParser,
xpath = require('xpath');
xpath = require('xpath'),
semver = require('semver');
// Verify the node version is new enough.
var expected = semver.validRange(grunt.file.readJSON('package.json').engines.node);
var actual = semver.valid(process.version);
if (!semver.satisfies(actual, expected)) {
grunt.fail.fatal('Node version too old. Require ' + expected + ', version installed: ' + actual);
}
// Windows users can't run grunt in a subdirectory, so allow them to set
// the root by passing --root=path/to/dir.

938
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,7 @@
"grunt-contrib-watch": "1.0.0",
"grunt-eslint": "19.0.0",
"grunt-stylelint": "0.6.0",
"semver": "5.3.0",
"shifter": "0.5.0",
"stylelint-checkstyle-formatter": "0.1.0",
"xmldom": "0.1.22",