-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenvars.js
More file actions
33 lines (30 loc) · 936 Bytes
/
envars.js
File metadata and controls
33 lines (30 loc) · 936 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
// add trailing slash
function trailSlash(str) {
if (str.substr(-1) != '/') {
str += '/';
}
return str
}
// wait for environment to be ready
exports.ready = function (callback) {
if (typeof process.env["API_BASE_URL"] == "undefined") {
// if API_BASE_URL is not defined, prompt user to define
(function (process, callback) {
var prompt = require('prompt');
prompt.start();
console.log('Missing environment variable');
prompt.get(['API_BASE_URL'], function (err, result) {
if (err) { return onErr(err); }
var url = trailSlash(result.API_BASE_URL);
console.log('API_BASE_URL: ' + url);
process.env["API_BASE_URL"] = url;
callback();
});
})(process, callback)
} else {
process.env["API_BASE_URL"] =
trailSlash(process.env["API_BASE_URL"]);
console.log('API_BASE_URL: ' + process.env["API_BASE_URL"]);
callback();
}
}