You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
|
|
export function isDebugging(key: string): boolean {
|
|
|
|
const env = 'EXTOLLO_DEBUG_' + key.split(/(?:\s|\.)+/).join('_')
|
|
|
|
.toUpperCase()
|
|
|
|
|
|
|
|
return process.env[env] === 'yes'
|
|
|
|
}
|
|
|
|
|
|
|
|
export function ifDebugging(key: string, run: () => any): void {
|
|
|
|
if ( isDebugging(key) ) {
|
|
|
|
run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function logIfDebugging(key: string, ...output: any[]): void {
|
|
|
|
ifDebugging(key, () => console.log(`[debug: ${key}]`, ...output)) // eslint-disable-line no-console
|
|
|
|
}
|