1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| 'use strict';
module.exports = core;
const semver = require('semver'); const colors = require('colors/safe'); const log = require('@xuven-cli-dev/log');
const constant = require('./const'); const pkg = require('../package.json');
function core() { try { checkPkgVersion(); checkNodeVersion(); checkRoot(); } catch (e) { log.error(e.message); } }
function checkRoot() { const rootCheck = require('root-check'); console.log(process.geteuid()); rootCheck(); console.log(process.geteuid()); }
function checkNodeVersion() { const currentVersion = process.version; const lowestVersion = constant.LOWEST_NODE_VERSION; if (!semver.gte(currentVersion, lowestVersion)) { throw new Error(colors.red(`xuven-cli-dev 需要安装 v${lowestVersion} 以上版本的 Node.js`)); } }
function checkPkgVersion() { log.info('cli', pkg.version); }
|