UNPKG

zhangjinxi-cli

Version:
47 lines (39 loc) 1.05 kB
#!/usr/bin/env node const fs = require('fs'); const chalk = require('chalk'); const semver = require('semver'); // 开始部署日志 function startLog(...content) { console.log(chalk.magenta(...content)); } // 信息日志 function infoLog(...content) { console.log(chalk.blue(...content)); } // 成功日志 function successLog(...content) { console.log(chalk.green(...content)); } // 错误日志 function errorLog(...content) { console.log(chalk.red(...content)); } // 下划线重点输出 function underlineLog(content) { return chalk.blue.underline.bold(`${content}`); } // 检查node版本是否符合特定范围 function checkNodeVersion(wanted, id) { if (!semver.satisfies(process.version, wanted)) { errorLog(`You ar using Node ${process.version}, but this version of ${id} requres Node ${wanted} .\nPlease upgrage your Node version.`); process.exit(1); } } module.exports = { startLog, infoLog, successLog, errorLog, underlineLog, checkNodeVersion };