Skip to content

Commit

Permalink
fix: support default fp (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
echosoar committed Jul 29, 2020
1 parent d088c2b commit 6c3d59c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/serverless-spec-builder/registerFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,24 @@ const registerFunctionToIocByConfig = (config, options) => {

try {
const modExports = require(functionPath);
if (!modExports || !modExports[functionName]) {
if (!modExports) {
return;
}
let fun;
if (functionName) {
fun = modExports[functionName];
} else {
fun = modExports.default || modExports;
}

if (typeof fun !== 'function') {
return;
}

registerFunctionToIoc(
options.context,
functionHandler || `${functionName}.handler`,
modExports[functionName]
functionHandler || `${functionName || '$default'}.handler`,
fun
);
} catch (error) {
console.error(
Expand Down

0 comments on commit 6c3d59c

Please sign in to comment.