Skip to content

Commit

Permalink
Add support for 'Indirect default export with a wrapping call at the …
Browse files Browse the repository at this point in the history
…export'
  • Loading branch information
James M. Greene authored and James M. Greene committed Nov 21, 2022
1 parent 24270f0 commit d897860
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/config-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,28 @@ class ConfigParser {

// Indirect default export with a wrapping call at the export
else if (
false
// ...
allowWrappingCall &&
defaultExport &&
defaultExport.declaration.type === 'CallExpression' &&
defaultExport.declaration.arguments.length > 0 &&
defaultExport.declaration.arguments[0] &&
defaultExport.declaration.arguments[0].type === 'Identifier'
) {
core.info('Found configuration object in indirect default export declaration with a wrapping call at the export')
return defaultExport.declaration.arguments[0]
const identifierName = defaultExport.declaration.arguments[0].name
const identifierDefinition = ast.body.find(
node =>
node.type === 'VariableDeclaration' &&
node.declarations.length == 1 &&
node.declarations[0].type === 'VariableDeclarator' &&
node.declarations[0].id.type === 'Identifier' &&
node.declarations[0].id.name === identifierName &&
node.declarations[0].init
)
const identifierInitialization = identifierDefinition && identifierDefinition.declarations[0].init
if (identifierInitialization && identifierInitialization.type === 'ObjectExpression') {
core.info('Found configuration object in indirect default export declaration with a wrapping call at the export')
return identifierInitialization
}
}

// Try to find a module export
Expand Down

0 comments on commit d897860

Please sign in to comment.