From 608dcd940ba2096d975dbbbedb63c34943617d4a Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Thu, 19 May 2022 09:33:44 +0100 Subject: [PATCH] fix: pages "command" can consist of multiple words (#1057) On Windows, the following command `wrangler pages dev -- foo bar` would error saying that `bar` was not a known argument. This is because `foo` and `bar` are passed to Yargs as separate arguments. A workaround is to put the command in quotes: `wrangler pages dev -- "foo bar"`. But this fix makes the `command` argument variadic, which also solves the problem. Fixes [#965](https://github.com/cloudflare/wrangler2/issues/965) --- .changeset/tame-tigers-impress.md | 14 ++++++++++++++ packages/wrangler/src/__tests__/pages.test.ts | 8 ++++---- packages/wrangler/src/pages.tsx | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 .changeset/tame-tigers-impress.md diff --git a/.changeset/tame-tigers-impress.md b/.changeset/tame-tigers-impress.md new file mode 100644 index 000000000000..624f38c6c563 --- /dev/null +++ b/.changeset/tame-tigers-impress.md @@ -0,0 +1,14 @@ +--- +"wrangler": patch +--- + +fix: pages "command" can consist of multiple words + +On Windows, the following command `wrangler pages dev -- foo bar` would error +saying that `bar` was not a known argument. This is because `foo` and `bar` are +passed to Yargs as separate arguments. + +A workaround is to put the command in quotes: `wrangler pages dev -- "foo bar"`. +But this fix makes the `command` argument variadic, which also solves the problem. + +Fixes [#965](https://github.com/cloudflare/wrangler2/issues/965) diff --git a/packages/wrangler/src/__tests__/pages.test.ts b/packages/wrangler/src/__tests__/pages.test.ts index c469f1f2fa30..bb5633283691 100644 --- a/packages/wrangler/src/__tests__/pages.test.ts +++ b/packages/wrangler/src/__tests__/pages.test.ts @@ -24,10 +24,10 @@ describe("pages", () => { ⚡️ Configure Cloudflare Pages Commands: - wrangler pages dev [directory] [-- command] 🧑‍💻 Develop your full-stack Pages application locally - wrangler pages project ⚡️ Interact with your Pages projects - wrangler pages deployment 🚀 Interact with the deployments of a project - wrangler pages publish [directory] 🆙 Publish a directory of static assets as a Pages deployment + wrangler pages dev [directory] [-- command..] 🧑‍💻 Develop your full-stack Pages application locally + wrangler pages project ⚡️ Interact with your Pages projects + wrangler pages deployment 🚀 Interact with the deployments of a project + wrangler pages publish [directory] 🆙 Publish a directory of static assets as a Pages deployment Flags: -c, --config Path to .toml configuration file [string] diff --git a/packages/wrangler/src/pages.tsx b/packages/wrangler/src/pages.tsx index 71548504fc0a..f3b77d3aef1b 100644 --- a/packages/wrangler/src/pages.tsx +++ b/packages/wrangler/src/pages.tsx @@ -1243,7 +1243,7 @@ const createDeployment: CommandModule< export const pages: BuilderCallback = (yargs) => { return yargs .command( - "dev [directory] [-- command]", + "dev [directory] [-- command..]", "🧑‍💻 Develop your full-stack Pages application locally", (yargs) => { return yargs