Skip to content

Commit caefe51

Browse files
authored
fix: Allow process.execPath to contain whitespace
This PR is a fix for the case when, like in my environment, `process.execPath` returns a path that includes a space: ``` /Users/komuro/Library/Application Support/fnm/node-versions/v18.6.0/installation/bin/node ``` The `containsSyntaxErrors` function calls `child_process.spawnSync()` with this string, which gives this error: ``` /bin/sh: /Users/komuro/Library/Application: No such file or directory ``` Since `child_process.spawnSync()` is called with `shell: true`, the first parameter can and should be passed as a quoted string to avoid problems with spaces. I wasn't able to figure out how to write a test in the integration framework that would test for this case... if this needs an integration test I will need help.
1 parent a03b698 commit caefe51

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/containsSyntaxErrors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { spawnSync } from "node:child_process";
33
// TODO: We should check that the syntax used is supported by our version of SpiderMonkey
44
export function containsSyntaxErrors(input) {
55
let nodeProcess = spawnSync(
6-
process.execPath,
6+
`"${process.execPath}"`,
77
[
88
"--check",
99
input,

0 commit comments

Comments
 (0)