这是我的NodeJs片段:
const {execSync} = require('child_process');
testoutput = execSync('make test');
在这里,如果make完全退出,我将从execSync进程获得stdout作为测试输出变量的输出。但是,如果make测试过程遇到stderr错误,那么我将在NodeJs中得到一个错误。
如果make进程没有退出,我如何将stderr消息存储到输出变量testoutput中,如果这个进程与stdout输出一起很好地退出,那么如何将stdout存储在变量testoutput中。
发布于 2022-07-12 01:31:42
要用execSync()
捕获错误,在调用时需要一个try/catch
,因为错误会引发异常。
https://stackoverflow.com/questions/72946118
复制相似问题