build(gulp): check node and npm version and log a warning if incompatible

Closes #1758
This commit is contained in:
Igor Minar 2015-05-07 22:37:35 -07:00 committed by Misko Hevery
parent d717529e9a
commit 31cbec0857
4 changed files with 41 additions and 1 deletions

View File

@ -3,6 +3,7 @@
var autoprefixer = require('gulp-autoprefixer');
var del = require('del');
var format = require('gulp-clang-format');
var exec = require('child_process').exec;
var fork = require('child_process').fork;
var gulp = require('gulp');
var gulpPlugins = require('gulp-load-plugins')();
@ -13,6 +14,7 @@ var madge = require('madge');
var merge = require('merge');
var merge2 = require('merge2');
var path = require('path');
var semver = require('semver');
var watch = require('gulp-watch');
var clean = require('./tools/build/clean');
@ -49,8 +51,37 @@ var angularBuilder = {
cleanup: function() {}
};
// Note: when DART_SDK is not found, all gulp tasks ending with `.dart` will be skipped.
(function checkNodeAndNpmVersions() {
var requiredNpmVersion = '>=2.9.0';
var requiredNodeVersion = '>=0.10.x'; // TODO: bump this to 0.12 once travis runs on 0.12
exec('npm --version', function(e, stdout) {
var foundNpmVersion = semver.clean(stdout);
var foundNodeVersion = process.version;
var issues = [];
if (!semver.satisfies(foundNodeVersion, requiredNodeVersion)) {
issues.push('You are running unsupported node version. Found: ' + foundNodeVersion +
' Expected: ' + requiredNodeVersion);
}
if (!semver.satisfies(foundNpmVersion, requiredNpmVersion)) {
issues.push('You are running unsuported npm version. Found: ' + foundNpmVersion +
' Expected: ' + requiredNpmVersion);
}
if (issues.length) {
// TODO: in the future we should error, but let's just display the warning for a few days first
console.warn(Array(80).join('!'));
console.warn('Your environment is not in a good shape. Following issues were found:');
issues.forEach(function(issue) {console.warn(' - ' + issue)});
console.warn(Array(80).join('!'));
}
});
}())
// Note: when DART_SDK is not found, all gulp tasks ending with `.dart` will be skipped.
var DART_SDK = require('./tools/build/dartdetect')(gulp);
// -----------------------

View File

@ -8382,6 +8382,9 @@
}
}
},
"semver": {
"version": "4.3.4"
},
"sorted-object": {
"version": "1.0.0"
},

5
npm-shrinkwrap.json generated
View File

@ -12951,6 +12951,11 @@
}
}
},
"semver": {
"version": "4.3.4",
"from": "semver@*",
"resolved": "https://registry.npmjs.org/semver/-/semver-4.3.4.tgz"
},
"sorted-object": {
"version": "1.0.0",
"from": "https://registry.npmjs.org/sorted-object/-/sorted-object-1.0.0.tgz",

View File

@ -100,6 +100,7 @@
"q": "^1.0.1",
"react": "^0.13.2",
"run-sequence": "^0.3.6",
"semver": "^4.3.4",
"sorted-object": "^1.0.0",
"source-map": "^0.3.0",
"sprintf-js": "1.0.*",