t-comm
Version:
专业、稳定、纯粹的工具库
43 lines (38 loc) • 1.13 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var tslib_es6 = require('../tslib.es6-01322ba9.js');
/* eslint-disable @typescript-eslint/no-require-imports */
/**
* 启动 uni-app 项目
* @param options 参数
*
* @example
* ```ts
* startUniProject();
*
* startUniProject({
* debug: false, // 默认为 true,会打印参数
* })
* ```
*/
function startUniProject(options) {
var _a;
var spawnSync = require('child_process').spawnSync;
var isWindows = require('os').platform() === 'win32';
var command = 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 = tslib_es6.__spreadArray(['run'], realArgv, true);
if (realArgv[0] === 'uni') {
command = isWindows ? 'npx.cmd' : 'npx';
otherArgv = realArgv;
}
spawnSync(command, otherArgv, {
stdio: 'inherit',
shell: true
});
}
exports.startUniProject = startUniProject;