From 8015401a87ece5bd900481a2aa017a2c876d8d20 Mon Sep 17 00:00:00 2001 From: Charles Stover Date: Tue, 11 Jul 2023 17:53:47 -0700 Subject: [PATCH] feat: support CJS configs in ES packages (#553) Co-authored-by: Lachlan Miller --- task-utils.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/task-utils.js b/task-utils.js index cd4360c1..7e39cfde 100644 --- a/task-utils.js +++ b/task-utils.js @@ -62,6 +62,16 @@ function readNycOptions(workingDirectory) { } } + const nycConfigCommonJsFilename = join(workingDirectory, 'nyc.config.cjs') + let nycConfigCommonJs = {} + if (existsSync(nycConfigCommonJsFilename)) { + try { + nycConfigCommonJs = require(nycConfigCommonJsFilename) + } catch (error) { + throw new Error(`Failed to load nyc.config.cjs: ${error.message}`) + } + } + const nycOptions = combineNycOptions( defaultNycOptions, nycrc, @@ -69,6 +79,7 @@ function readNycOptions(workingDirectory) { nycrcYaml, nycrcYml, nycConfig, + nycConfigCommonJs, pkgNycOptions ) debug('combined NYC options %o', nycOptions)