Switch execSync to spawnSync - #1523
Conversation
cd68b90 to
10521a9
Compare
10521a9 to
acd868f
Compare
LukeAbby
left a comment
There was a problem hiding this comment.
Looks like the windows failure is most likely due to the fact that I'd need to suffix pnpm with pnpm.cmd or something.
I think the better approach would be something like https://www.npmjs.com/package/cross-spawn though. It has the same API but fixes Node's deficiencies. Let me know what you think.
| shell(`${formatter} ${updatedPaths.join(" ")}`) | ||
| const command = formatter[0] | ||
| const args = formatter.slice(1) | ||
| shell(command, [...args, "--", ...updatedPaths]) |
There was a problem hiding this comment.
The extra -- is to prevent a filename named like --help from being interpreted as a flag. Arguably needs to be applied elsewhere but it gets increasingly difficult elsewhere since shell commands rarely are prepared to actually deal with dashes at the beginning of filenames in arbitrary locations.
|
Probably not going to prioritize reconciling this now, but thanks for taking a look. Sorry :S |
execandexecSyncboth document:While I'm not particularly worried about inputs being malicious (they are from the user provided paths) it's still a problem because shell metacharacters like
*,",',(space), etc. would all need handling since they are legal in paths.However this is a breaking change because
formatCmdchanged from astringto astring[]. If that's unacceptable I can instead do this:formatCwd: string.execSyncwhenformatCwdis a string andspawnSyncotherwise.formatCwd: string.Or I could try to find a package that implements quoting of user input to the shell.