File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,6 +40,21 @@ describe('Functions Command', () => {
4040 } ) ;
4141 } ) ;
4242
43+ it ( 'should fall back to process.cwd() when data-dir flag is not provided' , async ( ) => {
44+ Functions . prototype [ 'parse' ] = jest
45+ . fn ( )
46+ . mockResolvedValueOnce ( { flags : { 'data-dir' : undefined , port : '3000' } } ) ;
47+ const functionsCommand = new Functions ( [ ] , { } as any ) ;
48+
49+ await functionsCommand . init ( ) ;
50+
51+ expect ( Functions . prototype [ 'parse' ] ) . toHaveBeenCalledWith ( Functions ) ;
52+ expect ( functionsCommand [ 'sharedConfig' ] ) . toEqual ( {
53+ projectBasePath : process . cwd ( ) ,
54+ port : 3000 ,
55+ } ) ;
56+ } ) ;
57+
4358 it . each ( [ { portFlagInput : 'invalidPortInput' } , { portFlagInput : '999999' } , { portFlagInput : '-200' } ] ) (
4459 'should log an error and exit if the "port" flag input is invalid -> $portFlagInput' ,
4560 async ( { portFlagInput } ) => {
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ export default class Functions extends Command {
2222 } ) ,
2323 'data-dir' : Flags . string ( {
2424 char : 'd' ,
25- default : process . cwd ( ) ,
2625 description : 'Current working directory' ,
2726 } ) ,
2827 } ;
@@ -34,7 +33,8 @@ export default class Functions extends Command {
3433
3534 async init ( ) : Promise < void > {
3635 const { flags } = await this . parse ( Functions ) ;
37- const projectBasePath = flags [ 'data-dir' ] ;
36+ const currentWorkingDirectory = process . cwd ( ) ;
37+ const projectBasePath = flags [ 'data-dir' ] || currentWorkingDirectory ;
3838
3939 const logger = new Logger ( { projectBasePath } ) ;
4040 this . log = logger . log . bind ( logger ) ;
You can’t perform that action at this time.
0 commit comments