Timers and other features for Heroes of the Storm
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

70 lignes
2.0 KiB

  1. /*
  2. * Copyright © 2021 Adrien Agez <adrien.agez@pm.me>
  3. *
  4. * This file is part of Nexus Timers.
  5. *
  6. * Nexus Timers is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Nexus Timers is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with Nexus Timers. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. 'use strict'
  20. const chalk = require('chalk')
  21. const semver = require('semver')
  22. const packageConfig = require('../package.json')
  23. const shell = require('shelljs')
  24. function exec (cmd) {
  25. return require('child_process').execSync(cmd).toString().trim()
  26. }
  27. const versionRequirements = [
  28. {
  29. name: 'node',
  30. currentVersion: semver.clean(process.version),
  31. versionRequirement: packageConfig.engines.node
  32. },
  33. ]
  34. if (shell.which('npm')) {
  35. versionRequirements.push({
  36. name: 'npm',
  37. currentVersion: exec('npm --version'),
  38. versionRequirement: packageConfig.engines.npm
  39. })
  40. }
  41. module.exports = function () {
  42. const warnings = []
  43. for (let i = 0; i < versionRequirements.length; i++) {
  44. const mod = versionRequirements[i]
  45. if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
  46. warnings.push(mod.name + ': ' +
  47. chalk.red(mod.currentVersion) + ' should be ' +
  48. chalk.green(mod.versionRequirement)
  49. )
  50. }
  51. }
  52. if (warnings.length) {
  53. console.log('')
  54. console.log(chalk.yellow('To use this template, you must update following to modules:'))
  55. console.log()
  56. for (let i = 0; i < warnings.length; i++) {
  57. const warning = warnings[i]
  58. console.log(' ' + warning)
  59. }
  60. console.log()
  61. process.exit(1)
  62. }
  63. }