mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-17 16:37:43 +00:00
fix(build): auto-generate env.generated.ts on checkout via husky hook
This commit is contained in:
parent
0631d3e868
commit
34bf1d8277
2 changed files with 14 additions and 2 deletions
1
.husky/post-checkout
Normal file
1
.husky/post-checkout
Normal file
|
|
@ -0,0 +1 @@
|
|||
node tools/load-env.js --ensure
|
||||
|
|
@ -3,11 +3,22 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// --ensure flag: skip generation if env.generated.ts already exists
|
||||
// --ensure flag: create empty placeholder if env.generated.ts doesn't exist, skip otherwise
|
||||
const ensureOnly = process.argv.includes('--ensure');
|
||||
const configDir = path.join(process.cwd(), 'src/app/config');
|
||||
const outputPath = path.join(configDir, 'env.generated.ts');
|
||||
if (ensureOnly && fs.existsSync(outputPath)) {
|
||||
if (ensureOnly) {
|
||||
if (fs.existsSync(outputPath)) {
|
||||
process.exit(0);
|
||||
}
|
||||
if (!fs.existsSync(configDir)) {
|
||||
fs.mkdirSync(configDir, { recursive: true });
|
||||
}
|
||||
fs.writeFileSync(
|
||||
outputPath,
|
||||
`// This file is auto-generated by tools/load-env.js\n// Run 'npm run env' to populate with values from .env\n\nexport const ENV = {} as const;\n\nexport type EnvVars = typeof ENV;\n`,
|
||||
);
|
||||
console.log(`✅ Created placeholder ${outputPath}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue