-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathset-env.ts
More file actions
36 lines (33 loc) · 1.32 KB
/
Copy pathset-env.ts
File metadata and controls
36 lines (33 loc) · 1.32 KB
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
29
30
31
32
33
34
35
const writeFile = require('fs').writeFile;
// Configure Angular `environment.ts` file path
const environmentFilePaths = ['./src/environments/environment.prod.ts', './src/environments/environment.ts'];
// Load node modules
const colors = require('colors');
const dotevn = require('dotenv');
dotevn.config();
// `environment.ts` file structure
const envConfigFile = `export const environment = {
production: ${process.env["PRODUCTION"]},
apiBaseUrl: '${process.env["API_BASE_URL"]}',
firebase: {
apiKey: '${process.env["FIREBASE_API_KEY"]}',
authDomain: '${process.env["FIREBASE_AUTH_DOMAIN"]}',
projectId: '${process.env["FIREBASE_PROJECT_ID"]}',
storageBucket: '${process.env["FIREBASE_STORAGE_BUCKET"]}',
messagingSenderId: '${process.env["FIREBASE_MESSAGING_SENDER_ID"]}',
appId: '${process.env["FIREBASE_APP_ID"]}',
measurementId: '${process.env["FIREBASE_MEASUREMENT_ID"]}'
}
};
`;
console.log(colors.magenta('The file `environment.ts` will be written with the following content: \n'));
console.log(colors.grey(envConfigFile));
environmentFilePaths.forEach(filePath => {
writeFile(filePath, envConfigFile, function (err: any) {
if (err) {
throw console.error(err);
} else {
console.log(colors.magenta(`Angular environment.ts file generated correctly at ${filePath} \n`));
}
});
});