Skip to content

Commit 5fc7a88

Browse files
authored
fix usage of shell-quote.parse on windows (#4105)
1 parent 92c391c commit 5fc7a88

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/create-cloudflare/src/helpers/shell-quote.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import shellquote from "shell-quote";
33
export const quote = shellquote.quote;
44

55
export function parse(cmd: string, env?: Record<string, string>): string[] {
6+
// This is a workaround for a bug in shell-quote on Windows
7+
// It was fixed and, because it was a breaking change, then reverted
8+
// in https://github.com/ljharb/shell-quote/commit/144e1c2#diff-e727e4b
9+
// We can remove this once we upgrade to a version that includes the fix
10+
// tracked by https://github.com/ljharb/shell-quote/issues/10
11+
if (process.platform === "win32") {
12+
cmd = cmd.replaceAll("\\", "\\\\");
13+
}
14+
615
const entries = shellquote.parse(cmd, env);
716
const argv: string[] = [];
817

packages/wrangler/src/utils/shell-quote.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import shellquote from "shell-quote";
33
export const quote = shellquote.quote;
44

55
export function parse(cmd: string, env?: Record<string, string>): string[] {
6+
// This is a workaround for a bug in shell-quote on Windows
7+
// It was fixed and, because it was a breaking change, then reverted
8+
// in https://github.com/ljharb/shell-quote/commit/144e1c2#diff-e727e4b
9+
// We can remove this once we upgrade to a version that includes the fix
10+
// tracked by https://github.com/ljharb/shell-quote/issues/10
11+
if (process.platform === "win32") {
12+
cmd = cmd.replaceAll("\\", "\\\\");
13+
}
14+
615
const entries = shellquote.parse(cmd, env);
716
const argv: string[] = [];
817

0 commit comments

Comments
 (0)