easy-cli2
Version:
一个简易的脚手架,提供eslint格式化检查,创建项目模板,自动部署功能,xlsx与json互转,压缩图片等功能
64 lines (63 loc) • 2.15 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.npmCommand = void 0;
var shelljs_1 = __importDefault(require("shelljs"));
var util_1 = require("../../util");
var Npm = function (options) {
var check = options.check, list = options.list, taobao = options.taobao, url = options.url, reset = options.reset;
try {
if (check) {
shelljs_1.default.exec('npm config get registry');
}
else if (list) {
shelljs_1.default.exec('npm list -g --depth 0');
}
else if (reset) {
shelljs_1.default.exec('npm config set registry https://registry.npmjs.org/');
(0, util_1.loggerSuccess)('npm源已重置');
}
else if (taobao) {
shelljs_1.default.exec('npm config set registry https://registry.npm.taobao.org');
(0, util_1.loggerSuccess)('已将npm源设为淘宝镜像');
}
else if (url) {
shelljs_1.default.exec("npm config set registry ".concat(url));
(0, util_1.loggerSuccess)('npm源设置成功');
}
shelljs_1.default.exit(0);
}
catch (error) {
(0, util_1.loggerError)(error);
shelljs_1.default.exit(1);
}
};
exports.npmCommand = {
description: 'get npm version; set or get npm registry',
command: 'npm',
options: [
{
command: '-c --check',
description: 'check npm registry',
},
{
command: '-l --list',
description: 'check global installed package',
},
{
command: '-t --taobao',
description: 'set npm registry to taobao mirror',
},
{
command: '-r --reset',
description: 'reset npm registry',
},
{
command: '-u --url <registry-url>',
description: 'set npm registry',
},
],
action: Npm,
};