我具有用于调用指挥官脚本的此功能:
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
时是否需要执行某种类型的终结处理,以使句柄关闭?
对于完整的上下文this is the jest test script that contains the cli
function。