t-comm
Version:
专业、稳定、纯粹的工具库
48 lines (41 loc) • 1.49 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
var nodejs_child_process = require('../nodejs/child_process.js');
var validate_validate = require('../validate/validate.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
/**
* 启动 uni-app 项目
* @param options 参数
*
* @example
* ```ts
* startUniProject();
*
* startUniProject({
* debug: false, // 默认为 true,会打印参数
* })
* ```
*/
function startUniProject(options) {
var _a;
var _getChildProcess = nodejs_child_process.getChildProcess(),
spawnSync = _getChildProcess.spawnSync;
var command = validate_validate.isWindows() ? 'npm.cmd' : 'npm';
var realArgv = process.argv.slice(2);
var debug = (_a = options === null || options === void 0 ? void 0 : options.debug) !== null && _a !== void 0 ? _a : true;
if (debug) {
console.log('>>> startUniProject realArgv: ', realArgv);
}
var otherArgv = ['run'].concat(_toConsumableArray__default["default"](realArgv));
if (realArgv[0] === 'uni') {
command = validate_validate.isWindows() ? 'npx.cmd' : 'npx';
otherArgv = realArgv;
}
spawnSync(command, otherArgv, {
stdio: 'inherit',
shell: true
});
}
exports.startUniProject = startUniProject;