Open yaogengzhu opened 1 year ago
command 可以执行的 py, js 、直接可被执行的bin
const { exec } = require("child_process"); const p = new Promise((r) => { const command = "node my-script.js"; exec(command, (error, stdout, stderr) => { if (error) { return r({ success: false, error, msg: error.toString(), }); } return r({ success: true, error: null, msg: stdout, }); }); }); p.then((res) => { console.log(res); });
command 可以执行的 py, js 、直接可被执行的bin