Skip to content
Merged
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 a named environment (e.g. 'preview') or omit the flag.");
});
});
});
6 changes: 6 additions & 0 deletions src/cli/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export async function deploy(options: SWACLIConfig) {
}
}

// make sure --env is not an empty string
if (options.env !== undefined && !options.env.trim()) {
logger.error("Invalid --env: cannot be empty. Use a named environment (e.g. 'preview') or omit the flag.");
return;
}

logger.silly(`Resolving outputLocation=${outputLocation} full path...`);
let resolvedOutputLocation = path.resolve(appLocation, outputLocation as string);

Expand Down
Loading