-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset-env.js
More file actions
21 lines (17 loc) · 724 Bytes
/
set-env.js
File metadata and controls
21 lines (17 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
// Get the environment argument, defaulting to "development"
const env = process.env.BUILD_ENV || 'dev'; // Options: development, stg, production
// Define the corresponding environment file
const envFile = `.env.${env}`;
const targetFile = path.join(__dirname, '.env');
// Check if the environment file exists
if (!fs.existsSync(envFile)) {
console.error(`❌ Error: ${envFile} does not exist.`);
process.exit(1);
}
// Copy the correct environment file to `.env`
fs.copyFileSync(envFile, targetFile);
console.log(`✅ Successfully set environment: ${envFile} → .env`);