From dba1438225c3d3552bd306fec5f57332c9b10aed Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 2 Apr 2019 06:41:12 +0200 Subject: [PATCH] inline interopDefault in config loading (#2782) --- bin/src/run/loadConfigFile.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bin/src/run/loadConfigFile.ts b/bin/src/run/loadConfigFile.ts index 5dea8f008f4..03c02d28565 100644 --- a/bin/src/run/loadConfigFile.ts +++ b/bin/src/run/loadConfigFile.ts @@ -10,10 +10,6 @@ interface NodeModuleWithCompile extends NodeModule { _compile(code: string, filename: string): any; } -function interopDefault(ex: T): T { - return ex && typeof ex === 'object' && 'default' in ex ? (ex as any).default : ex; -} - export default function loadConfigFile( configFile: string, commandOptions: any = {} @@ -54,8 +50,9 @@ export default function loadConfigFile( delete require.cache[configFile]; - return Promise.resolve(interopDefault(require(configFile))) + return Promise.resolve(require(configFile)) .then(configFileContent => { + if (configFileContent.default) configFileContent = configFileContent.default; if (typeof configFileContent === 'function') { return configFileContent(commandOptions); }