From cf672d1d266c01763a4abbda0c443df1837dd954 Mon Sep 17 00:00:00 2001 From: Filipe Pomar Date: Sat, 25 Nov 2023 20:24:54 +0100 Subject: [PATCH 1/2] feat: added support for nyc configuration throw environment variables --- task-utils.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/task-utils.js b/task-utils.js index 7e39cfde..f591fd61 100644 --- a/task-utils.js +++ b/task-utils.js @@ -72,8 +72,21 @@ function readNycOptions(workingDirectory) { } } + let nycConfigEnvVariables = {} + if (process.env.NYC_CONFIG) { + try { + nycConfigEnvVariables = JSON.parse(process.env.NYC_CONFIG) + if (nycConfigEnvVariables === null || typeof nycConfigEnvVariables !== 'object') { + throw new Error('NYC_CONFIG environment configuration is set, but it is not an object as expected') + } + } catch (error) { + throw new Error(`Failed to load environment NYC_CONFIG: ${error.message}`) + } + } + const nycOptions = combineNycOptions( defaultNycOptions, + nycConfigEnvVariables, nycrc, nycrcJson, nycrcYaml, @@ -82,6 +95,7 @@ function readNycOptions(workingDirectory) { nycConfigCommonJs, pkgNycOptions ) + debug('combined NYC options %o', nycOptions) return nycOptions From 79237cc7c7614a848270f7c734925c395712f38b Mon Sep 17 00:00:00 2001 From: Filipe Pomar Date: Sun, 26 Nov 2023 15:05:29 +0100 Subject: [PATCH 2/2] style: formatted file changes from previous commit --- task-utils.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/task-utils.js b/task-utils.js index f591fd61..adc73310 100644 --- a/task-utils.js +++ b/task-utils.js @@ -76,8 +76,13 @@ function readNycOptions(workingDirectory) { if (process.env.NYC_CONFIG) { try { nycConfigEnvVariables = JSON.parse(process.env.NYC_CONFIG) - if (nycConfigEnvVariables === null || typeof nycConfigEnvVariables !== 'object') { - throw new Error('NYC_CONFIG environment configuration is set, but it is not an object as expected') + if ( + nycConfigEnvVariables === null || + typeof nycConfigEnvVariables !== 'object' + ) { + throw new Error( + 'NYC_CONFIG environment configuration is set, but it is not an object as expected' + ) } } catch (error) { throw new Error(`Failed to load environment NYC_CONFIG: ${error.message}`)