mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
3d54b2bd90
Former-commit-id: 0d8742754bb756ad3a83599850dae5f477282430 [formerly 5cb7d75b695d8400fc2af87edd551d6450e7365f] [formerly a6a814c40a5ff4f195c4ab470d4fccc92bd8c1c8 [formerly 99c8c92c6c
]]
Former-commit-id: 45eba5ff05f8e64fbf33d9d670e19a0cf4880656 [formerly 88dc856045b9d51596f36ce387b1c4f3e85a7d3c]
Former-commit-id: 1eadaef460060da8ae71df3c66f242c844992725
49 lines
1.3 KiB
JavaScript
49 lines
1.3 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)
|
|
}
|
|
}
|