fix: extend parsing of boolean environment vars

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-03-02 20:49:40 +01:00
parent 29b3562672
commit e2b84e134a
2 changed files with 11 additions and 1 deletions

View file

@ -3,9 +3,14 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
function isPositiveAnswer (value) {
const lowerValue = value.toLowerCase()
return lowerValue === 'yes' || lowerValue === '1' || lowerValue === 'true'
}
exports.toBooleanConfig = function toBooleanConfig (configValue) { exports.toBooleanConfig = function toBooleanConfig (configValue) {
if (configValue && typeof configValue === 'string') { if (configValue && typeof configValue === 'string') {
return (configValue === 'true') return (isPositiveAnswer(configValue))
} }
return configValue return configValue
} }

View file

@ -1,5 +1,10 @@
# Release Notes # Release Notes
## UNRELEASED
### Enhancements
- Extend boolean environment variable parsing with other positive answers and case insensitivity.
## <i class="fa fa-tag"></i> 1.9.7 <i class="fa fa-calendar-o"></i> 2023-02-19 ## <i class="fa fa-tag"></i> 1.9.7 <i class="fa fa-calendar-o"></i> 2023-02-19
### Bugfixes ### Bugfixes