Skip to content

Commit 77c5daf

Browse files
committed
fix project ref cli arg override
1 parent 3179dfc commit 77c5daf

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

packages/cli-v3/src/commands/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function configureDeployCommand(program: Command) {
9494
.option("-c, --config <config file>", "The name of the config file, found at [path]")
9595
.option(
9696
"-p, --project-ref <project ref>",
97-
"The project ref. Required if there is no config file."
97+
"The project ref. Required if there is no config file. This will override the project specified in the config file."
9898
)
9999
)
100100
.addOption(

packages/cli-v3/src/utilities/configFiles.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,13 @@ export async function readConfig(
164164

165165
// import the config file
166166
const userConfigModule = await import(builtConfigFileHref);
167+
168+
// The --project-ref CLI arg will always override the project specified in the config file
167169
const rawConfig = await normalizeConfig(
168-
userConfigModule ? userConfigModule.config : { project: options?.projectRef }
170+
userConfigModule?.config,
171+
options?.projectRef ? { project: options?.projectRef } : undefined
169172
);
173+
170174
const config = Config.parse(rawConfig);
171175

172176
return {
@@ -198,10 +202,14 @@ export async function resolveConfig(path: string, config: Config): Promise<Resol
198202
return config as ResolvedConfig;
199203
}
200204

201-
export async function normalizeConfig(config: any): Promise<any> {
205+
export async function normalizeConfig(config: any, overrides?: Record<string, any>): Promise<any> {
206+
let normalized = config;
207+
202208
if (typeof config === "function") {
203-
config = config();
209+
normalized = await config();
204210
}
205211

206-
return await config;
212+
normalized = { ...normalized, ...overrides };
213+
214+
return normalized;
207215
}

0 commit comments

Comments
 (0)