filebrowser/assets/build/check-versions.js
Henrique Dias 963a7ffdf3 More updates
Former-commit-id: ec1b6164ad91ca53e9032dac1b4f07bc46bbf092 [formerly 51a9aba6c47da2bec069944c85e9e8ce01a13e72] [formerly b305bc377e8fb452548c73778aba277588995009 [formerly cd1dce5bc8]]
Former-commit-id: 98f7c2689cc193c0a5fc035943716a4d999180bd [formerly e49d2368e7427b2089916ee965345850f461c0cd]
Former-commit-id: 84df75990151d151ba00c9b5e84fe8eeb3573e64
2017-07-06 08:25:09 +01:00

49 lines
1.2 KiB
JavaScript

var chalk = require('chalk')
var semver = require('semver')
var packageConfig = require('../../package.json')
var shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}
var versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
}
]
if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}
module.exports = function () {
var warnings = []
for (var i = 0; i < versionRequirements.length; i++) {
var mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (var i = 0; i < warnings.length; i++) {
var warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}