diff options
Diffstat (limited to 'tools/tasks/check.versions.ts')
-rw-r--r-- | tools/tasks/check.versions.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/tasks/check.versions.ts b/tools/tasks/check.versions.ts new file mode 100644 index 0000000..211d5ed --- /dev/null +++ b/tools/tasks/check.versions.ts @@ -0,0 +1,35 @@ +import {VERSION_NPM, VERSION_NODE} from '../config'; + +function reportError(message: string) { + console.error(require('chalk').white.bgRed.bold(message)); + process.exit(1); +} + +module.exports = function check(gulp, plugins) { + return function () { + let exec = require('child_process').exec; + let semver = require('semver'); + + exec('npm --version', + function (error, stdout, stderr) { + if (error !== null) { + reportError('npm preinstall error: ' + error + stderr); + } + + if (!semver.gte(stdout, VERSION_NPM)) { + reportError('NPM is not in required version! Required is ' + VERSION_NPM + ' and you\'re using ' + stdout); + } + }); + + exec('node --version', + function (error, stdout, stderr) { + if (error !== null) { + reportError('npm preinstall error: ' + error + stderr); + } + + if (!semver.gte(stdout, VERSION_NODE)) { + reportError('NODE is not in required version! Required is ' + VERSION_NODE + ' and you\'re using ' + stdout); + } + }); + }; +}; |