Skip to content

Commit

Permalink
MDL-55856 grunt: fail gracefully when node version too old
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
danpoltawski committed Sep 15, 2016
1 parent 1f27448 commit d2c7175
Show file tree
Hide file tree
Showing 3 changed files with 479 additions and 470 deletions.
10 changes: 9 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit d2c7175

Please sign in to comment.