Javascript 使用node exec时是否打开句柄?
我使用此函数调用指挥官脚本:Javascript 使用node exec时是否打开句柄?,javascript,node.js,jestjs,Javascript,Node.js,Jestjs,我使用此函数调用指挥官脚本: function cli(args, cwd) { return new Promise(resolve => { exec( `node ${path.resolve("./index")} ${args.join(" ")}`, { cwd }, (error, stdout, stderr) => { resolve({
function cli(args, cwd) {
return new Promise(resolve => {
exec(
`node ${path.resolve("./index")} ${args.join(" ")}`,
{ cwd },
(error, stdout, stderr) => {
resolve({
code: error && error.code ? error.code : 0,
error,
stdout,
stderr
});
}
);
});
}
在某些调用中,Jest会记录以下内容:
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● PROCESSWRAP
255 | function cli(args, cwd) {
256 | return new Promise(resolve => {
> 257 | exec(
| ^
258 | `node ${path.resolve("./index")} ${args.join(" ")}`,
259 | { cwd },
260 | (error, stdout, stderr) => {
at exec (index.spec.js:257:5)
at cli (index.spec.js:256:10)
at Object.cli (index.spec.js:89:24)
使用exec
时是否需要执行某种类型的终结,以使句柄关闭
完整的上下文