forked from novuhq/novu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-env-files.js
28 lines (23 loc) · 967 Bytes
/
setup-env-files.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const fs = require('fs');
const path = require('path');
const prePopulateEnv = (folders, folderBasePath, exampleEnvFilePath = 'src/.example.env', envFilePath = 'src/.env') => {
for (const folder of folders) {
const exists = fs.existsSync(path.resolve(`${folderBasePath}/${folder}/${envFilePath}`));
if (!exists) {
console.log(`Populating ${folderBasePath}/${folder} with .env file`);
fs.copyFileSync(
path.resolve(`${folderBasePath}/${folder}/${exampleEnvFilePath}`),
path.resolve(`${folderBasePath}/${folder}/${envFilePath}`)
);
}
}
};
(async () => {
const apps = ['api', 'ws', 'worker'];
const appsBasePath = `${__dirname}/../apps`;
console.log('----------------------------------------');
console.log('Pre-populating .env files from .example.env');
prePopulateEnv(apps, appsBasePath);
console.log('Finished populating .env files');
console.log('----------------------------------------');
})();