forked from novuhq/novu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-env-files.js
25 lines (23 loc) · 1.01 KB
/
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
const fs = require('fs');
const path = require('path');
const prePopulateEnv = (apps, folderBasePath, exampleEnvFilePath = 'src/.example.env', envFilePath = 'src/.env') => {
console.log(`Pre-populating .env files from .example.env for [${apps.join(',')}]`);
for (const folder of apps) {
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 appsBasePath = `${__dirname}/../apps`;
console.log('----------------------------------------');
prePopulateEnv(['api', 'ws', 'worker'], appsBasePath);
prePopulateEnv(['web', 'widget'], appsBasePath, '.example.env', '.env');
console.log('Finished populating .env files');
console.log('----------------------------------------');
})();