Timers and other features for Heroes of the Storm
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

51 linhas
1.3 KiB

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