24 lines
636 B
TypeScript
24 lines
636 B
TypeScript
const DEBUG_MODE_TRUE_VALUES = new Set(['1', 'true', 'yes', 'on']);
|
|
const DEBUG_MODE_FALSE_VALUES = new Set(['0', 'false', 'no', 'off']);
|
|
|
|
function parseOptionalBoolean(value: string | undefined) {
|
|
const normalizedValue = value?.trim().toLowerCase();
|
|
if (!normalizedValue) {
|
|
return null;
|
|
}
|
|
if (DEBUG_MODE_TRUE_VALUES.has(normalizedValue)) {
|
|
return true;
|
|
}
|
|
if (DEBUG_MODE_FALSE_VALUES.has(normalizedValue)) {
|
|
return false;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export const IS_DEBUG_MODE =
|
|
parseOptionalBoolean(import.meta.env.VITE_DEBUG_MODE) ?? import.meta.env.DEV;
|
|
|
|
export function isDebugMode() {
|
|
return IS_DEBUG_MODE;
|
|
}
|