-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcreate-env.ts
24 lines (20 loc) · 896 Bytes
/
create-env.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* @description This script will create some .env files in the env folder based on the .env.example file in the root project.
* @author {Deo Sbrn}
*/
import { existsSync, mkdirSync, readFileSync } from 'fs';
import { writeFile } from 'fs/promises';
import clc from 'cli-color';
const envExample = readFileSync('./env/.env.example', 'utf8');
const environments = ['local', 'development', 'staging', 'production', 'production.local'];
environments.forEach(async (environment) => {
if (!existsSync('./env')) mkdirSync('./env');
try {
await writeFile(`./env/.env.${environment}`, envExample);
console.log(clc.green(`.env.${environment} file created successfully! ✅`));
} catch (err) {
console.log(clc.red('Something went wrong. ❌'));
console.log(clc.cyan('Please contact the owner of this template! ❕'));
process.exit(1);
}
});