forked from GetStream/stream-chat-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset-env.ts
More file actions
37 lines (30 loc) · 956 Bytes
/
set-env.ts
File metadata and controls
37 lines (30 loc) · 956 Bytes
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
36
37
const fs = require('fs');
const writeFile = fs.writeFile;
const targetPath = `projects/sample-app/src/environments/environment.ts`;
require('dotenv').config();
const devEnvConfig = {
production: false,
};
const prodEnvConfig = {
production: true,
};
const envConfig: { [key: string]: any } =
process.env.ANGULAR_ENV === 'production' ? prodEnvConfig : devEnvConfig;
// `environment.ts` file structure
const envConfigFile = `export const environment = {
${Object.keys(envConfig).map((k) => `${k}: ${envConfig[k]},`)}
apiKey: '${process.env.STREAM_API_KEY}',
userId: '${process.env.STREAM_USER_ID}',
userToken: '${process.env.STREAM_USER_TOKEN}'
};
// I am a generated file, do not modify me directly, see set-env script
`;
writeFile(targetPath, envConfigFile, (err: any) => {
if (err) {
throw err;
} else {
console.log(
`Angular environment.ts file generated correctly at ${targetPath} \n`
);
}
});