t-comm
Version:
专业、稳定、纯粹的工具库
39 lines (36 loc) • 1.04 kB
JavaScript
import { a as __spreadArray } from '../tslib.es6-096fffdd.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 = __spreadArray(['run'], realArgv, true);
if (realArgv[0] === 'uni') {
command = isWindows ? 'npx.cmd' : 'npx';
otherArgv = realArgv;
}
spawnSync(command, otherArgv, {
stdio: 'inherit',
shell: true
});
}
export { startUniProject };