Before people start crying "duplicate", I've already examined
- Spawning process with arguments in node.js
- Use NodeJS spawn to call node script with arguments
- How do I pass command line arguments to a Node.js program?
The first of these is basically the same question in a different use case and as a result the answers do not address my use case.
So... how do you encode a command line like the following with named parameters separated from their values by a space?
arduino-cli compile --fqbn arduino:avr:nano
Should it look like this (1)?
let cp = child.process(
"/path/to/arduino-cli.exe",
[
"compile",
"--fqbn arduino:avr:nano"
]
);
or this (2)?
let cp = child.process(
"/path/to/arduino-cli.exe",
[
"compile",
"--fqbn",
"arduino:avr:nano"
]
);
or this (3)?
let cp = child.process(
"/path/to/arduino-cli.exe",
[
"compile",
"fqbn",
"arduino:avr:nano"
]
);
or this (4)?
let cp = child.process(
"/path/to/arduino-cli.exe",
{
_: ["compile"],
fqbn: "arduino:avr:nano"
}
);
TypeScript won't allow the last option even though I suspect it is the right answer, so I submit the problem for wider consideration.