-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate-env.js
executable file
·35 lines (30 loc) · 1.3 KB
/
generate-env.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 fs = require('fs')
const dotenv = require('dotenv')
dotenv.config()
const envsPath = './src/environments'
if (!fs.existsSync(envsPath)) {
fs.mkdirSync(envsPath)
}
const api_url = process.env.API_GATEWAY_SERVICE
const node_env = process.env.NODE_ENV
const ls_secret_key = process.env.LS_SECRET_KEY
const reCaptcha_siteKey = process.env.RECAPTCHA_KEY
const dashboard_host = process.env.DASHBOARD_HOST
var wstream = fs.createWriteStream(envsPath + '/environment.ts')
wstream.write('export const environment = {\n')
wstream.write(`\tproduction: ${node_env === 'production'},\n`)
wstream.write('\tapi_url: "' + api_url + '",\n')
wstream.write('\tls_secret_key: "' + ls_secret_key + '",\n')
wstream.write('\treCaptcha_siteKey: "' + reCaptcha_siteKey + '",\n')
wstream.write('\tdashboard_host: "' + dashboard_host + '",\n')
wstream.write('};\n')
wstream.end()
var wstream = fs.createWriteStream(envsPath + '/environment.prod.ts')
wstream.write('export const environment = {\n')
wstream.write(`\tproduction: ${node_env === 'production'},\n`)
wstream.write('\tapi_url: "' + api_url + '",\n')
wstream.write('\tls_secret_key: "' + ls_secret_key + '",\n')
wstream.write('\treCaptcha_siteKey: "' + reCaptcha_siteKey + '",\n')
wstream.write('\tdashboard_host: "' + dashboard_host + '",\n')
wstream.write('};\n')
wstream.end()