-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci-script.js
35 lines (29 loc) · 900 Bytes
/
ci-script.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
26
27
28
29
30
31
32
33
34
35
const { dir } = require("console");
const fs = require("fs");
const path = require("path");
const envDir = "src/environments";
const envFile = "environment.ts";
const envFileProd = "environment.prod.ts";
const envContents = String.raw`import { IEnvironment } from "./env.interface";
export const environment: IEnvironment = {
production: ${process.env["PRODUCTION"] === "true"},
cipher_key: "${process.env["CIPHER_KEY"]}",
backend_url: "${process.env["BACKEND_URL"]}",
};
`;
fs.access(envDir, fs.constants.F_OK, err => {
if (err) {
console.log(`${envDir} doesn't exist, creating one.`);
fs.mkdir(envDir, e => {
if (e) throw e;
});
}
try {
fs.writeFileSync(`${envDir}/${envFile}`, "");
fs.writeFileSync(`${envDir}/${envFileProd}`, envContents);
console.log(`Created env and env.prod files in ${envDir}`);
} catch (error) {
console.error(error);
process.exit(1);
}
});