diff --git a/packages/create-cloudflare/src/helpers/shell-quote.ts b/packages/create-cloudflare/src/helpers/shell-quote.ts index 5903cbb92daf..21ad74c95760 100644 --- a/packages/create-cloudflare/src/helpers/shell-quote.ts +++ b/packages/create-cloudflare/src/helpers/shell-quote.ts @@ -3,6 +3,15 @@ import shellquote from "shell-quote"; export const quote = shellquote.quote; export function parse(cmd: string, env?: Record): string[] { + // This is a workaround for a bug in shell-quote on Windows + // It was fixed and, because it was a breaking change, then reverted + // in https://github.com/ljharb/shell-quote/commit/144e1c2#diff-e727e4b + // We can remove this once we upgrade to a version that includes the fix + // tracked by https://github.com/ljharb/shell-quote/issues/10 + if (process.platform === "win32") { + cmd = cmd.replaceAll("\\", "\\\\"); + } + const entries = shellquote.parse(cmd, env); const argv: string[] = []; diff --git a/packages/wrangler/src/utils/shell-quote.ts b/packages/wrangler/src/utils/shell-quote.ts index 5903cbb92daf..21ad74c95760 100644 --- a/packages/wrangler/src/utils/shell-quote.ts +++ b/packages/wrangler/src/utils/shell-quote.ts @@ -3,6 +3,15 @@ import shellquote from "shell-quote"; export const quote = shellquote.quote; export function parse(cmd: string, env?: Record): string[] { + // This is a workaround for a bug in shell-quote on Windows + // It was fixed and, because it was a breaking change, then reverted + // in https://github.com/ljharb/shell-quote/commit/144e1c2#diff-e727e4b + // We can remove this once we upgrade to a version that includes the fix + // tracked by https://github.com/ljharb/shell-quote/issues/10 + if (process.platform === "win32") { + cmd = cmd.replaceAll("\\", "\\\\"); + } + const entries = shellquote.parse(cmd, env); const argv: string[] = [];