Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wrangler): support -C, --cwd cli argument #7994

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/khaki-years-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": minor
---

Add `-C, --cwd` global argument to the `wrangler` CLI to allow changing the current working directory before running any command.
2 changes: 2 additions & 0 deletions packages/wrangler/src/__tests__/ai.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe("ai help", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down Expand Up @@ -55,6 +56,7 @@ describe("ai help", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down
1 change: 1 addition & 0 deletions packages/wrangler/src/__tests__/cert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe("cloudchamber create", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe("cloudchamber curl", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe("cloudchamber delete", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe("cloudchamber image", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe("cloudchamber list", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe("cloudchamber modify", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down
4 changes: 4 additions & 0 deletions packages/wrangler/src/__tests__/d1/d1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe("d1", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down Expand Up @@ -66,6 +67,7 @@ describe("d1", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down Expand Up @@ -95,6 +97,7 @@ describe("d1", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down Expand Up @@ -123,6 +126,7 @@ describe("d1", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down
1 change: 1 addition & 0 deletions packages/wrangler/src/__tests__/deployments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe("deployments", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down
1 change: 1 addition & 0 deletions packages/wrangler/src/__tests__/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,7 @@ describe.sequential("wrangler dev", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down
1 change: 1 addition & 0 deletions packages/wrangler/src/__tests__/docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe("wrangler docs", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down
2 changes: 2 additions & 0 deletions packages/wrangler/src/__tests__/hyperdrive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe("hyperdrive help", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down Expand Up @@ -69,6 +70,7 @@ describe("hyperdrive help", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down
15 changes: 15 additions & 0 deletions packages/wrangler/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -126,6 +127,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -154,6 +156,14 @@ describe("wrangler", () => {
`[Error: The argument "--config" expects a single value, but received multiple: ["wrangler.toml","example"].]`
);
});

it("should change cwd with -C, --cwd", async () => {
const spy = vi.spyOn(process, "chdir").mockImplementation(() => {});
await Promise.all([runWrangler("-C /path"), runWrangler("--cwd /path")]);
expect(process.chdir).toHaveBeenCalledTimes(2);
expect(process.chdir).toHaveBeenCalledWith("/path");
spy.mockRestore();
});
});

describe("preview", () => {
Expand Down Expand Up @@ -192,6 +202,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand All @@ -213,6 +224,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand All @@ -235,6 +247,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand All @@ -255,6 +268,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand All @@ -275,6 +289,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down
16 changes: 16 additions & 0 deletions packages/wrangler/src/__tests__/kv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand All @@ -69,6 +70,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down Expand Up @@ -97,6 +99,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down Expand Up @@ -141,6 +144,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -172,6 +176,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -623,6 +628,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -664,6 +670,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -705,6 +712,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -746,6 +754,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -787,6 +796,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -1156,6 +1166,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -1192,6 +1203,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -1229,6 +1241,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down Expand Up @@ -1800,6 +1813,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand All @@ -1820,6 +1834,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand All @@ -1838,6 +1853,7 @@ describe("wrangler", () => {

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
-C, --cwd Run as if Wrangler was started in the specified directory instead of the current working directory [string]
-e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]"
Expand Down
Loading
Loading