From 9a82bc05b23455c1cbc50baec8778269b02c0074 Mon Sep 17 00:00:00 2001 From: Charles Stover Date: Wed, 23 Feb 2022 15:36:55 -0600 Subject: [PATCH] support CJS configs in ES packages --- 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)