我正在尝试使用目标设备启动cordova 命令。我已经测试了该命令并且它可以工作,但是当我尝试用我的代码生成它时,它会忽略等号,因此不会运行。这段代码确实有效,只是不添加"--target='iPhone-7-Plus"
return new Promise((resolve, reject) => {
const executable = "ionic";
const arguments = [
"cordova",
buildOnly ? "build" : "run",
platform,
"--no-interactive",
"--verbose",
"--target='iPhone-7-Plus'"
].concat(releaseDev === "release" ? ["--prod", "--release"] : []);
console.log(executable, arguments.join(" "));
const child = spawn(executable, arguments, {
stdio: "inherit"
});
child.on("close", () => resolve());
child.on("error", err => reject(err));
});
我在这里做错了什么?为什么它只会忽略我的等号,但会添加其余的命令?
如果我运行cordova run ios --target='iPhone-7-Plus'
该命令将执行并启动 7+ 模拟器而不会出现问题。
生成时,我必须添加shell: true
以便为我的 os.s 使用默认 shell。spawn 使用的外壳会去除特殊字符。
const child = spawn(executable, arguments, {
stdio: "inherit",
shell: true
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句