Skip to content

Commit df62d4e

Browse files
committed
fix: npm failing to pass args to wrangler
1 parent 81af13b commit df62d4e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/strange-icons-camp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
fix: npm failing to pass args to wrangler

packages/cloudflare/src/cli/utils/run-wrangler.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ type WranglerOptions = {
1313
};
1414

1515
export function runWrangler(options: BuildOptions, args: string[], wranglerOpts: WranglerOptions = {}) {
16+
const flagInArgsIndex = args.findIndex((v) => v.startsWith("--"));
17+
const needsPassthroughFlag = options.packager === "npm" || options.packager === "yarn";
18+
1619
const result = spawnSync(
1720
options.packager,
1821
[
1922
options.packager === "bun" ? "x" : "exec",
2023
"wrangler",
21-
...args,
24+
...(needsPassthroughFlag && flagInArgsIndex !== -1
25+
? [...args.slice(0, flagInArgsIndex), "--", ...args.slice(flagInArgsIndex)]
26+
: args),
2227
wranglerOpts.environment && `--env ${wranglerOpts.environment}`,
2328
wranglerOpts.target === "remote" && !wranglerOpts.excludeRemoteFlag && "--remote",
2429
wranglerOpts.target === "local" && "--local",

0 commit comments

Comments
 (0)