Skip to content

Commit

Permalink
fix usage of shell-quote.parse on windows (#4105)
Browse files Browse the repository at this point in the history
  • Loading branch information
RamIdeas authored Oct 4, 2023
1 parent 92c391c commit 5fc7a88
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/create-cloudflare/src/helpers/shell-quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import shellquote from "shell-quote";
export const quote = shellquote.quote;

export function parse(cmd: string, env?: Record<string, string>): 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[] = [];

Expand Down
9 changes: 9 additions & 0 deletions packages/wrangler/src/utils/shell-quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import shellquote from "shell-quote";
export const quote = shellquote.quote;

export function parse(cmd: string, env?: Record<string, string>): 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[] = [];

Expand Down

0 comments on commit 5fc7a88

Please sign in to comment.