git ssb

0+

dangerousbeans / etherstreams



Tree: 5b2e405d30a0a28a8d6b43dd4ec8b16cdba28cf8

Files: 5b2e405d30a0a28a8d6b43dd4ec8b16cdba28cf8 / build / check-versions.js

1256 bytesRaw
1var chalk = require('chalk')
2var semver = require('semver')
3var packageConfig = require('../package.json')
4var shell = require('shelljs')
5function exec (cmd) {
6 return require('child_process').execSync(cmd).toString().trim()
7}
8
9var versionRequirements = [
10 {
11 name: 'node',
12 currentVersion: semver.clean(process.version),
13 versionRequirement: packageConfig.engines.node
14 }
15]
16
17if (shell.which('npm')) {
18 versionRequirements.push({
19 name: 'npm',
20 currentVersion: exec('npm --version'),
21 versionRequirement: packageConfig.engines.npm
22 })
23}
24
25module.exports = function () {
26 var warnings = []
27 for (var i = 0; i < versionRequirements.length; i++) {
28 var mod = versionRequirements[i]
29 if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
30 warnings.push(mod.name + ': ' +
31 chalk.red(mod.currentVersion) + ' should be ' +
32 chalk.green(mod.versionRequirement)
33 )
34 }
35 }
36
37 if (warnings.length) {
38 console.log('')
39 console.log(chalk.yellow('To use this template, you must update following to modules:'))
40 console.log()
41 for (var i = 0; i < warnings.length; i++) {
42 var warning = warnings[i]
43 console.log(' ' + warning)
44 }
45 console.log()
46 process.exit(1)
47 }
48}
49

Built with git-ssb-web