Skip to content

Commit 7c0ed9e

Browse files
committed
output more wrangler command logs in debug mode
1 parent 7159f6f commit 7c0ed9e

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

.changeset/fresh-taxis-pay.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+
output more wrangler command logs in debug mode

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function injectPassthroughFlagForArgs(options: BuildOptions, args: string[]) {
5656
}
5757

5858
export function runWrangler(options: BuildOptions, args: string[], wranglerOpts: WranglerOptions = {}) {
59-
const result = spawnSync(
59+
const spawnArgs = [
6060
options.packager,
6161
[
6262
options.packager === "bun" ? "x" : "exec",
@@ -72,19 +72,24 @@ export function runWrangler(options: BuildOptions, args: string[], wranglerOpts:
7272
].filter((v): v is string => !!v)
7373
),
7474
],
75-
{
76-
shell: true,
77-
stdio: wranglerOpts.logging === "error" ? ["ignore", "ignore", "inherit"] : "inherit",
78-
env: {
79-
...process.env,
80-
...(wranglerOpts.logging === "error" ? { WRANGLER_LOG: "error" } : undefined),
81-
// `.env` files are handled by the adapter.
82-
// Wrangler would load `.env.<wrangler env>` while we should load `.env.<process.env.NEXTJS_ENV>`
83-
// See https://opennext.js.org/cloudflare/howtos/env-vars
84-
CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV: "false",
85-
},
86-
}
87-
);
75+
] as const;
76+
77+
// ensure the logs are on a new line so they don't get appended to tqdm progress bars
78+
if (options.debug) console.log();
79+
logger.debug(`Running wrangler command: ${spawnArgs.flat().join(" ")}`);
80+
81+
const result = spawnSync(...spawnArgs, {
82+
shell: true,
83+
stdio: !options.debug && wranglerOpts.logging === "error" ? ["ignore", "ignore", "inherit"] : "inherit",
84+
env: {
85+
...process.env,
86+
...(!options.debug && wranglerOpts.logging === "error" ? { WRANGLER_LOG: "error" } : undefined),
87+
// `.env` files are handled by the adapter.
88+
// Wrangler would load `.env.<wrangler env>` while we should load `.env.<process.env.NEXTJS_ENV>`
89+
// See https://opennext.js.org/cloudflare/howtos/env-vars
90+
CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV: "false",
91+
},
92+
});
8893

8994
if (result.status !== 0) {
9095
logger.error("Wrangler command failed");

0 commit comments

Comments
 (0)