Skip to content

Commit af3bb34

Browse files
author
deepshekhardas
committed
fix(cli): respect --profile flag by deferring default evaluation
The CommonCommandOptions Zod schema used .default(readAuthConfigCurrentProfileName()) which evaluates the default profile at module load time. When a user passes --profile <name>, the Zod schema already has the default value set and ignores the CLI argument. Changed to .optional().transform(v => v ?? readAuthConfigCurrentProfileName()) so the fallback is evaluated lazily at parse time, only when no --profile flag is provided. Fixes #2542
1 parent e1f8134 commit af3bb34

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/cli-v3/src/cli/common.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export const CommonCommandOptions = z.object({
1313
apiUrl: z.string().optional(),
1414
logLevel: z.enum(["debug", "info", "log", "warn", "error", "none"]).default("log"),
1515
skipTelemetry: z.boolean().default(false),
16-
profile: z.string().default(readAuthConfigCurrentProfileName()),
16+
profile: z
17+
.string()
18+
.optional()
19+
.transform((v) => v ?? readAuthConfigCurrentProfileName()),
1720
});
1821

1922
export type CommonCommandOptions = z.infer<typeof CommonCommandOptions>;

0 commit comments

Comments
 (0)