summaryrefslogtreecommitdiff
path: root/lib/leftpadesque/debug.ts
blob: f38154096d09a2536cb095bb3a035dc805877828 (plain) (blame)
1
2
3
4
5
6
7
8
9
const _hasEnv = true; // Node.js always has access to environment variables

const _env: 'development' | 'production' =
    _hasEnv && (process.env.ENVIRONMENT ?? '').toLowerCase().includes('prod') ? 'production' : 'development';
export const isProd = () => _env === 'production';

const _debugEnv = (process.env.DEBUG ?? '').toLowerCase();
const _debug = !isProd() || (_hasEnv && ['y', 't'].some((prefix) => _debugEnv.startsWith(prefix)));
export const isDebug = () => _debug;