Fix "Duplicate environment variable" error message never showing up (#6740)

This commit is contained in:
Pascal Jufer
2021-07-11 09:52:57 +02:00
committed by GitHub
parent c599c076c0
commit fb0e02cd4b

View File

@@ -181,14 +181,14 @@ function processValues(env: Record<string, any>) {
// and store it in the variable with the same name but without '_FILE' at the end
let newKey;
if (key.length > 5 && key.endsWith('_FILE')) {
newKey = key.slice(0, -5);
if (newKey in env) {
throw new Error(
`Duplicate environment variable encountered: you can't use "${newKey}" and "${key}" simultaneously.`
);
}
try {
value = fs.readFileSync(value, { encoding: 'utf8' });
newKey = key.slice(0, -5);
if (newKey in env) {
throw new Error(
`Duplicate environment variable encountered: you can't use "${key}" and "${newKey}" simultaneously.`
);
}
key = newKey;
} catch {
throw new Error(`Failed to read value from file "${value}", defined in environment variable "${key}".`);