storebound/apps/desktop/src/dev/switches.ts

10 lines
663 B
TypeScript

// Dev-only switches for screenshots and manual checks: VITE_START / VITE_THEME / VITE_LANG / VITE_AUTORUN, or the same
// names as URL query parameters (?start=app:health&theme=dark&lang=tr) in the Vite dev server. Release builds compile
// import.meta.env.DEV to false, so this always answers "" there.
export type Switch = 'start' | 'theme' | 'lang' | 'autorun';
export function devSwitch(name: Switch): string {
if (!import.meta.env.DEV) return '';
const q = typeof location !== 'undefined' ? new URLSearchParams(location.search).get(name) : null;
return q ?? String((import.meta.env as Record<string, unknown>)[`VITE_${name.toUpperCase()}`] ?? '');
}