Skip to content
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
8 changes: 8 additions & 0 deletions src/cli/commands/deploy/deploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,13 @@ describe("deploy", () => {
expect(env.FUNCTION_LANGUAGE_VERSION).toBe(DEFAULT_VERSION.DotnetIsolated);
expect(SUPPORTED_VERSIONS.DotnetIsolated).toContain(env.FUNCTION_LANGUAGE_VERSION);
});

it("should print an error when --env is an empty string", async () => {
await deploy({
outputLocation: "/test-output",
env: "",
});
expect(logger.error).toHaveBeenNthCalledWith(1, "Invalid --env: cannot be empty. Use 'preview' or omit the flag.");
});
});
});
4 changes: 4 additions & 0 deletions src/cli/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ export async function deploy(options: SWACLIConfig) {
// set the DEPLOYMENT_ENVIRONMENT env variable only when the user has provided
// a deployment environment which is not "production".
if (options.env?.toLowerCase() !== "production" && options.env?.toLowerCase() !== "prod") {
if (options.env !== undefined && !options.env.trim()) {
logger.error("Invalid --env: cannot be empty. Use 'preview' or omit the flag.");
return;
}
deployClientEnv.DEPLOYMENT_ENVIRONMENT = options.env;
}

Expand Down
Loading