zoukankan      html  css  js  c++  java
  • check-versions.js和dev-client.js

    // 用于在控制台输出带颜色字体的插件
    var chalk = require('chalk')

    // 语义化版本检查插件(The semantic version parser used by npm)
    var semver = require('semver')

    // 引入package.json
    var packageConfig = require('../package.json')

    // 开辟子进程执行指令cmd并返回结果
    function exec (cmd) {
    return require('child_process').execSync(cmd).toString().trim()
    }

    // node和npm版本需求

    var versionRequirements = [
    {
    name: 'node',
    currentVersion: semver.clean(process.version),
    versionRequirement: packageConfig.engines.node
    },
    {
    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)
    }
    }

  • 相关阅读:
    实验任务四
    java语言基础第二讲 课程作业02 总结
    java 计算精度处理
    构建之法阅读笔记02
    周活动总结表
    周进度条
    构建之法阅读笔记01
    四则运算软件需求规格说明书
    四则运算2
    周进度条
  • 原文地址:https://www.cnblogs.com/moneyss/p/7098655.html
Copyright © 2011-2022 走看看