This repository was archived by the owner on Mar 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset-env.ts
More file actions
40 lines (36 loc) · 1.29 KB
/
set-env.ts
File metadata and controls
40 lines (36 loc) · 1.29 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
36
37
38
39
40
const fs = require('fs');
require('dotenv').config();
if (process !== undefined && process.env.PRODUCTION !== undefined && process.env.CRYPTR_CONFIG !== undefined && process.env.RS_URL !== undefined) {
const envConfigFile = `export const environment = {
production: ${process.env.PRODUCTION},
cryptrConfig: ${process.env.CRYPTR_CONFIG},
resource_server_url: '${process.env.RS_URL}',
targetUrl: '${process.env.CRYPTR_TARGET_URL}'
};
`;
const targetPath = './projects/playground/src/environments/environment.prod.ts';
console.log(`The file '${targetPath}' will be written with the following content: \n`);
console.log(envConfigFile);
fs.exists("./projects/playground/src/environments/environment.prod.ts", (exists: boolean) => {
if (exists) {
fs.unlink("./projects/playground/src/environments/environment.prod.ts", (err: Error) => {
if (err) {
throw err;
}
fs.writeFile(
"./projects/playground/src/environments/environment.prod.ts",
envConfigFile,
{ flag: "wx" },
(err: Error) => {
if (err) {
throw err;
}
})
});
} else {
console.error("file not found :/");
}
});
} else {
console.info("no .env variable found -> use files");
}