chore: fix --version weird error

This commit is contained in:
Ralph Khreish
2025-09-23 11:45:46 +02:00
parent 100482722f
commit 6bbd777552
3 changed files with 20 additions and 26 deletions

View File

@@ -7,6 +7,16 @@ dotenvLoad();
// Get all TM_PUBLIC_* env variables for build-time injection
const getBuildTimeEnvs = () => {
const envs: Record<string, string> = {};
// Inject package.json version at build time
try {
const packageJson = JSON.parse(require('fs').readFileSync('package.json', 'utf8'));
envs['TM_PUBLIC_VERSION'] = packageJson.version || 'unknown';
} catch (error) {
console.warn('Could not read package.json version during build:', error);
envs['TM_PUBLIC_VERSION'] = 'unknown';
}
for (const [key, value] of Object.entries(process.env)) {
if (key.startsWith('TM_PUBLIC_')) {
// Return the actual value, not JSON.stringify'd