settings: clarify that null defaults are supported, using the syntax "${VAR_NAME}"

Using "${VAR_NAME:null}", instead, would define the literal string "null".
This commit is contained in:
muxator 2020-04-21 03:40:49 +02:00 committed by muxator
parent 68ff6d497d
commit 9882362e2e
3 changed files with 15 additions and 1 deletions

View file

@ -421,6 +421,14 @@ function storeSettings(settingsObj) {
/*
* If stringValue is a numeric string, or its value is "true" or "false", coerce
* them to appropriate JS types. Otherwise return stringValue as-is.
*
* Please note that this function is used for converting types for default
* values in the settings file (for example: "${PORT:9001}"), and that there is
* no coercition for "null" values.
*
* If the user wants a variable to be null by default, he'll have to use the
* short syntax "${ABIWORD}", and not "${ABIWORD:null}": the latter would result
* in the literal string "null", instead.
*/
function coerceValue(stringValue) {
// cooked from https://stackoverflow.com/questions/175739/built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number
@ -525,7 +533,7 @@ function lookupEnvironmentVariables(obj) {
const defaultValue = match[3];
if ((envVarValue === undefined) && (defaultValue === undefined)) {
console.warn(`Environment variable "${envVarName}" does not contain any value for configuration key "${key}", and no default was given. Returning null. Please check your configuration and environment settings.`);
console.warn(`Environment variable "${envVarName}" does not contain any value for configuration key "${key}", and no default was given. Returning null.`);
/*
* We have to return null, because if we just returned undefined, the