From 8e221f24dba2e3fa025303e69169a4130770ddc0 Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Mon, 21 Nov 2022 12:05:26 -0600 Subject: [PATCH] Add support for 'Indirect module export with a wrapping call at the definition' --- src/config-parser.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/config-parser.js b/src/config-parser.js index 9f987c4..e28e2f7 100644 --- a/src/config-parser.js +++ b/src/config-parser.js @@ -236,21 +236,24 @@ class ConfigParser { node.declarations[0].type === 'VariableDeclarator' && node.declarations[0].id.type === 'Identifier' && node.declarations[0].id.name === identifierName && - node.declarations[0].init.type === 'ObjectExpression' + node.declarations[0].init ) - if (identifierDefinition) { + const identifierInitialization = identifierDefinition && identifierDefinition.declarations[0].init + if (identifierInitialization && identifierInitialization.type === 'ObjectExpression') { core.info('Found configuration object in indirect module export') - return identifierDefinition.declarations[0].init + return identifierInitialization + } + // Indirect module export with a wrapping call at the definition + else if ( + identifierInitialization && + identifierInitialization.type === 'CallExpression' && + identifierInitialization.arguments.length > 0 && + identifierInitialization.arguments[0] && + identifierInitialization.arguments[0].type === 'ObjectExpression' + ) { + core.info('Found configuration object in indirect module export with a wrapping call at the definition') + return identifierInitialization.arguments[0] } - } - - // Indirect default export with a wrapping call at the definition - else if ( - false - // ... - ) { - core.info('Found configuration object in indirect module export with a wrapping call at the definition') - return defaultExport.declaration.arguments[0] } // Indirect default export with a wrapping call at the export