Skip to content

Commit

Permalink
feat(config): config.CI to override env.CI
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Prioritize config over environment variables when resolving value for CI
  • Loading branch information
AriPerkkio committed Nov 4, 2020
1 parent 015a78c commit 377a869
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
4 changes: 1 addition & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ jobs:
command: yarn test
- run:
name: Integration test
command: yarn test:integration
environment:
CI: 'null'
command: yarn test:integration
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = {
/** ESLint configuration */
eslintrc: {},

/** Optional boolean flag used to set CI mode. Ignored when process.env.CI is set. */
/** Optional boolean flag used to set CI mode. process.env.CI is used when not set. */
CI: false,
}
```
Expand Down
2 changes: 1 addition & 1 deletion lib/config/config-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ export const CONFIGURATION_FILE_TEMPLATE =
},
},
/** Optional boolean flag used to set CI mode. Ignored when process.env.CI is set. */
/** Optional boolean flag used to set CI mode. process.env.CI is used when not set. */
CI: false,
}`;
7 changes: 2 additions & 5 deletions lib/config/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ export default function constructAndValidateConfiguration(
if (CI != null && typeof CI !== 'boolean') {
errors.push(`CI (${CI}) should be a boolean.`);
} else {
// Resolve CI from environment variables, if found. Fallback to configuration file.
config.CI =
process.env.CI == null || process.env.CI == 'null'
? CI
: process.env.CI === 'true';
// Resolve CI from configuration file, if found. Fallback to environment variables.
config.CI = CI == null ? process.env.CI === 'true' : CI;
}

if (resultParser && !RESULT_PARSERS.includes(resultParser)) {
Expand Down

0 comments on commit 377a869

Please sign in to comment.