No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

hace 3 años
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. }