-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
darian
committed
Nov 5, 2024
1 parent
ee6f208
commit c7f177b
Showing
2 changed files
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import path from 'node:path' | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
|
||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = path.dirname(__filename) | ||
const envFilePath = join(__dirname, '.env'); | ||
const mode = process.argv[2] || 'hot-reload'; | ||
|
||
function updateDevEnvVariable() { | ||
let envContent = readFileSync(envFilePath, 'utf8'); | ||
|
||
if (envContent.includes('DEV_MODE=')) { | ||
envContent = envContent.replace(/DEV_MODE=.*/g, `DEV_MODE=${mode}`); | ||
} else { | ||
envContent += `\nDEV_MODE=${mode}`; | ||
} | ||
|
||
writeFileSync(envFilePath, envContent.trim() + '\n'); | ||
} | ||
|
||
updateDevEnvVariable(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters