UNPKG

l2en-cli

Version:

cli,项目脚手架,快速搭建项目框架

31 lines 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var fs = require('fs-extra'); var path = require('path'); var jsonFormat = require('json-format'); function writePkg(projectDir, projectName, opts) { if (projectDir === void 0) { projectDir = ''; } if (projectName === void 0) { projectName = ''; } if (opts === void 0) { opts = {}; } var _a = opts, _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.description, description = _c === void 0 ? '' : _c, _d = _a.keywords, keywords = _d === void 0 ? '' : _d, _e = _a.author, author = _e === void 0 ? '' : _e; return new Promise(function (resolve, reject) { if (fs.pathExistsSync(projectDir)) { var project_pkg = fs.readFileSync(path.resolve(projectDir + "/package.json"), 'utf-8'); var newPkg = tslib_1.__assign(tslib_1.__assign({}, JSON.parse(project_pkg)), { name: name, description: description, keywords: keywords, author: author }); fs.writeFileSync(path.resolve(projectDir + "/package.json"), jsonFormat(newPkg, { type: 'space', size: 2 }), 'utf-8'); resolve(''); } else { reject(projectName + " is not exist!"); } }); } exports.default = writePkg; //# sourceMappingURL=writePkg.js.map