Skip to content

Commit 5b1f128

Browse files
committed
feat(wrangler): support -C, --cwd
1 parent 59c7c8e commit 5b1f128

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

packages/wrangler/src/api/dev.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export async function unstable_dev(
183183
ip: "127.0.0.1",
184184
inspectorPort: options?.inspectorPort ?? 0,
185185
v: undefined,
186+
cwd: undefined,
186187
localProtocol: options?.localProtocol,
187188
httpsKeyPath: options?.httpsKeyPath,
188189
httpsCertPath: options?.httpsCertPath,

packages/wrangler/src/generate/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export async function generateHandler(args: GenerateArgs) {
5353
delegateC3: false,
5454
v: undefined,
5555
config: undefined,
56+
cwd: undefined,
5657
env: undefined,
5758
type: undefined,
5859
_: args._,

packages/wrangler/src/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,19 @@ export function createCLIParser(argv: string[]) {
223223
alias: "version",
224224
type: "boolean",
225225
})
226+
.option("cwd", {
227+
describe:
228+
"Run as if wrangler was started in <path> instead of the current working directory.",
229+
alias: "C",
230+
type: "string",
231+
requiresArg: true,
232+
})
233+
.check(demandSingleValue("cwd"))
234+
.middleware((argv) => {
235+
if (argv.cwd) {
236+
process.chdir(argv.cwd);
237+
}
238+
})
226239
.option("config", {
227240
alias: "c",
228241
describe: "Path to Wrangler configuration file",
@@ -301,7 +314,7 @@ export function createCLIParser(argv: string[]) {
301314
"Examples:": `${chalk.bold("EXAMPLES")}`,
302315
});
303316
wrangler.group(
304-
["config", "env", "help", "version"],
317+
["config", "cwd", "env", "help", "version"],
305318
`${chalk.bold("GLOBAL FLAGS")}`
306319
);
307320
wrangler.help("help", "Show help").alias("h", "help");

packages/wrangler/src/pages/dev.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ export const Handler = async (args: PagesDevArguments) => {
895895
processEntrypoint: true,
896896
additionalModules: modules,
897897
v: undefined,
898+
cwd: undefined,
898899
assets: undefined,
899900
name: undefined,
900901
noBundle: false,

packages/wrangler/src/yargs-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { ArgumentsCamelCase, Argv, CommandModule } from "yargs";
66
*/
77
export interface CommonYargsOptions {
88
v: boolean | undefined;
9+
cwd: string | undefined;
910
config: string | undefined;
1011
env: string | undefined;
1112
"experimental-provision": boolean | undefined;

0 commit comments

Comments
 (0)