Skip to content

Commit 27619d4

Browse files
committed
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.
1 parent 6501dc8 commit 27619d4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

server/src/__tests__/config.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ describe('highlightParsingError', () => {
6262
let result = config.getHighlightParsingError()
6363
expect(result).toEqual(true)
6464

65+
process.env = {
66+
HIGHLIGHT_PARSING_ERRORS: '1',
67+
}
68+
result = config.getHighlightParsingError()
69+
expect(result).toEqual(true)
70+
71+
process.env = {
72+
HIGHLIGHT_PARSING_ERRORS: '0',
73+
}
74+
result = config.getHighlightParsingError()
75+
expect(result).toEqual(false)
76+
6577
process.env = {
6678
HIGHLIGHT_PARSING_ERRORS: 'false',
6779
}

server/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ export function getGlobPattern(): string {
1717
export function getHighlightParsingError(): boolean {
1818
const { HIGHLIGHT_PARSING_ERRORS } = process.env
1919
return typeof HIGHLIGHT_PARSING_ERRORS !== 'undefined'
20-
? HIGHLIGHT_PARSING_ERRORS === 'true'
20+
? HIGHLIGHT_PARSING_ERRORS === 'true' || HIGHLIGHT_PARSING_ERRORS === '1'
2121
: true
2222
}

0 commit comments

Comments
 (0)