forked from truenas/webui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_env.js
More file actions
executable file
·33 lines (26 loc) · 825 Bytes
/
setup_env.js
File metadata and controls
executable file
·33 lines (26 loc) · 825 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
#!/usr/bin/env node
var program = require('commander');
program
.option('-i, --ip <ip_address>', 'IP address of your server')
.parse(process.argv);
var proxy_config_json = './proxy.config.json';
var environment_ts = './src/environments/environment.ts';
var hostname = (program.ip || '').match(/^(?:https?:\/\/)?(?:[^@\n]+@)?([^:\/\n?]+)/);
if (!hostname || !hostname[1]) {
program.outputHelp();
process.exit(2);
}
var copySkel = function(file) {
var fs = require('fs')
fs.readFile(file + '.skel', 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
var result = data.replace(/\$SERVER\$/g, hostname[1]);
fs.writeFile(file, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});
}
copySkel(proxy_config_json);
copySkel(environment_ts);