File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -307,5 +307,13 @@ describe("deploy", () => {
307307 expect ( env . FUNCTION_LANGUAGE_VERSION ) . toBe ( DEFAULT_VERSION . DotnetIsolated ) ;
308308 expect ( SUPPORTED_VERSIONS . DotnetIsolated ) . toContain ( env . FUNCTION_LANGUAGE_VERSION ) ;
309309 } ) ;
310+
311+ it ( "should print an error when --env is an empty string" , async ( ) => {
312+ await deploy ( {
313+ outputLocation : "/test-output" ,
314+ env : "" ,
315+ } ) ;
316+ expect ( logger . error ) . toHaveBeenNthCalledWith ( 1 , "Invalid --env: cannot be empty. Use 'preview' or omit the flag." ) ;
317+ } ) ;
310318 } ) ;
311319} ) ;
Original file line number Diff line number Diff line change @@ -255,6 +255,10 @@ export async function deploy(options: SWACLIConfig) {
255255 // set the DEPLOYMENT_ENVIRONMENT env variable only when the user has provided
256256 // a deployment environment which is not "production".
257257 if ( options . env ?. toLowerCase ( ) !== "production" && options . env ?. toLowerCase ( ) !== "prod" ) {
258+ if ( options . env !== undefined && ! options . env . trim ( ) ) {
259+ logger . error ( "Invalid --env: cannot be empty. Use 'preview' or omit the flag." ) ;
260+ return ;
261+ }
258262 deployClientEnv . DEPLOYMENT_ENVIRONMENT = options . env ;
259263 }
260264
You can’t perform that action at this time.
0 commit comments