I'm trying to launch a cordova command with a target device. I've tested the command and it works but when I try to generate it with my code, it ignores the equal sign and therefore won't run. This code does work just not with the addition of "--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));
});
What am I doing wrong here? Why would it be ignoring my equal sign only but the rest of the command gets added?
If I run cordova run ios --target='iPhone-7-Plus'
the command will execute and launch the 7+ simulator without issues.
When spawning I had to add shell: true
in order to use the default shell for my os. The shell that spawn was using would strip special characters.
const child = spawn(executable, arguments, {
stdio: "inherit",
shell: true
});