From 27619d4e463ade91d21704d5ea9ca876f8c69413 Mon Sep 17 00:00:00 2001 From: Damien R Date: Fri, 1 May 2020 01:27:58 +0200 Subject: [PATCH] Support 0/1 as value for HIGHLIGHT_PARSING_ERRORS We permit to specify 0 or 1 as value for HIGHLIGHT_PARSING_ERRORS because the variable has a boolean type and because it is common to use these values for feature toggle in environment variables. --- server/src/__tests__/config.test.ts | 12 ++++++++++++ server/src/config.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/server/src/__tests__/config.test.ts b/server/src/__tests__/config.test.ts index 755a188bf..44763bac2 100644 --- a/server/src/__tests__/config.test.ts +++ b/server/src/__tests__/config.test.ts @@ -62,6 +62,18 @@ describe('highlightParsingError', () => { let result = config.getHighlightParsingError() expect(result).toEqual(true) + process.env = { + HIGHLIGHT_PARSING_ERRORS: '1', + } + result = config.getHighlightParsingError() + expect(result).toEqual(true) + + process.env = { + HIGHLIGHT_PARSING_ERRORS: '0', + } + result = config.getHighlightParsingError() + expect(result).toEqual(false) + process.env = { HIGHLIGHT_PARSING_ERRORS: 'false', } diff --git a/server/src/config.ts b/server/src/config.ts index 712f8022e..41b0a9056 100644 --- a/server/src/config.ts +++ b/server/src/config.ts @@ -17,6 +17,6 @@ export function getGlobPattern(): string { export function getHighlightParsingError(): boolean { const { HIGHLIGHT_PARSING_ERRORS } = process.env return typeof HIGHLIGHT_PARSING_ERRORS !== 'undefined' - ? HIGHLIGHT_PARSING_ERRORS === 'true' + ? HIGHLIGHT_PARSING_ERRORS === 'true' || HIGHLIGHT_PARSING_ERRORS === '1' : true }