UNPKG

ci-plus

Version:

ci组件库

16 lines (14 loc) 567 B
import { spawn } from 'child_process'; export default async (command: string, path: string) => { //cmd表示命令,args代表参数,如 rm -rf rm就是命令,-rf就为参数 const [cmd, ...args] = command.split(' '); return new Promise((resolve) => { const app = spawn(cmd, args, { cwd: path, //执行命令的路径 stdio: 'inherit', //输出共享给父进程 shell: true //mac不需要开启,windows下git base需要开启支持 }); //执行完毕关闭并resolve app.on('close', resolve); }); };