我使用以下代码来获取目标文件
const command = `make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\\/t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'`;
cp.exec(command, options, (error, stdout, stderr) => {
if (error) {
reject({ error, stdout, stderr });
}
当通过代码使用它时出现错误(Windows)
"'$)' is not recognized as an internal or external command,
operable program or batch file.
"
但是,如果我在终端可以运行]上运行确切的命令,则!!!!可能是什么问题呢?
顺便说一句,在Mac上,代码正在工作,是否有任何解决方法,正则表达式会丢失什么?
我也尝试过使用https://github.com/shelljs/shelljs并得到完全相同的错误,也许我错过了一些转义符?
我用这个
https://nodejs.org/api/child_process.html#child_process_class_childprocess
我使用以下代码来获取make文件目标const command =`make -qp | awk -F':''/ ^ [a-zA-Z0-9] [^ $#\\ / t =] *:([^ =] | $)/ {split($ 1,A,/ /); for(i in A)print A [i]}'`; cp.exec(命令,选项,(...
不能完全回答您的问题,但是我建议您使用https://github.com/shelljs/shelljs来避免浪费时间在不同平台上的命令之间。