UNPKG

xbp-cli

Version:

A simple CLI for scaffolding Vue.js projects.

49 lines (44 loc) 1.33 kB
const program = require('commander'); const childProcess = require('child_process') const inquirer = require('inquirer') /** * 执行指令 * @param {*} param0 * @returns */ exports.CmdAction = ({ path, command }) => { return new Promise((resolve, reject) => { const spawnName = "xbp"; const commandList = [command]; console.log( "spawnName>>>>>>", spawnName, command, "path>>>>>>", path ) const compile = childProcess.spawn(spawnName, commandList, { cwd: path, stdio: "inherit", shell: true }) compile.on("close", (code) => { resolve(); }) }) } /** * 启动命令集合 */ program.command("start [appName] [command]") .description("run the given remote command") .option("-a, --app [appName]") .option("-c, --command [command]") .parse(process.argv) .action(async function (app, npmCommand) { // await exports.CmdAction({ path: './bin', command:'-V'}); // await exports.CmdAction({ path: './bin', command:'-h'}); // await exports.CmdAction({ path: './bin', command:'list'}); await exports.CmdAction({ path: './bin', command:'init myproject'}); }); program.parse(process.argv);