-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathset-env.ts
35 lines (29 loc) · 1.02 KB
/
set-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
25
26
27
28
29
30
31
32
33
34
35
const fs = require('fs');
const colors = require('colors');
// Configure Angular `environment.ts` file path
let targetPath = '';
if (process.env.PRODUCTION === 'true') {
targetPath = './src/environments/environment.prod.ts';
} else {
targetPath = './src/environments/environment.ts';
}
// Load node modules
require('dotenv').config();
// `environment.ts` file structure
const envConfigFile = `export const environment = {
production: ${process.env.PRODUCTION},
githubToken: '${process.env.GITHUB_TOKEN}',
githubOrgName: '${process.env.GITHUB_ORG_NAME}',
githubApiUrl: '${process.env.GITHUB_API_URL}',
pageSize: ${process.env.PAGE_SIZE},
};
`;
console.log(colors.magenta('The file `environment.ts` will be written with the following content: \n'));
console.log(colors.grey(envConfigFile));
fs.writeFile(targetPath, envConfigFile, (err) => {
if (err) {
throw console.error(err);
} else {
console.log(colors.magenta(`Angular environment.ts file generated correctly at ${targetPath} \n`));
}
});