@@ -48,10 +48,16 @@ module.exports = {
4848 return path . extname ( _ . first ( sortedFiles ) ) ;
4949 }
5050
51- const getEntryForFunction = serverlessFunction => {
51+ const getEntryForFunction = ( name , serverlessFunction ) => {
5252 const handler = serverlessFunction . handler ;
53- const handlerFile = / ( .* ) \. .* ?$ / . exec ( handler ) [ 1 ] ;
54-
53+ // Check if handler is a well-formed path based handler.
54+ const handlerEntry = / ( .* ) \. .* ?$ / . exec ( handler ) ;
55+ if ( ! handlerEntry ) {
56+ _ . get ( this . serverless , 'service.provider.name' ) !== 'google' &&
57+ this . serverless . cli . log ( `\nWARNING: Entry for ${ name } @${ handler } could not be retrieved.\nPlease check your service config if you want to use lib.entries.` ) ;
58+ return { } ;
59+ }
60+ const handlerFile = handlerEntry [ 1 ] ;
5561 const ext = getEntryExtension ( handlerFile ) ;
5662
5763 // Create a valid entry key
@@ -70,12 +76,12 @@ module.exports = {
7076 const entries = { } ;
7177 const functions = this . serverless . service . getAllFunctions ( ) ;
7278 if ( this . options . function ) {
73- const serverlessFunction = this . serverless . service . getFunction ( this . options . function ) ;
74- const entry = getEntryForFunction ( serverlessFunction ) ;
79+ const serverlessFunction = this . serverless . service . getFunction ( this . options . function ) ;
80+ const entry = getEntryForFunction . call ( this , this . options . function , serverlessFunction ) ;
7581 _ . merge ( entries , entry ) ;
7682 } else {
77- _ . forEach ( functions , func => {
78- const entry = getEntryForFunction ( this . serverless . service . getFunction ( func ) ) ;
83+ _ . forEach ( functions , ( func , index ) => {
84+ const entry = getEntryForFunction . call ( this , functions [ index ] , this . serverless . service . getFunction ( func ) ) ;
7985 _ . merge ( entries , entry ) ;
8086 } ) ;
8187 }
0 commit comments