made more command line flags do things
This commit is contained in:
parent
3633c7570b
commit
2eb6d1bc95
|
@ -69,6 +69,7 @@ function readConfigAndRun(args) {
|
|||
|
||||
var recase = require('recase').create({});
|
||||
config = recase.camelCopy(config);
|
||||
config.debug = config.debug || args.debug;
|
||||
|
||||
if (!config.dns) {
|
||||
config.dns = { modules: [{ name: 'proxy', port: 3053 }] };
|
||||
|
@ -85,15 +86,17 @@ function readConfigAndRun(args) {
|
|||
config.http = { modules: [{ name: 'proxy', domains: ['*'], port: 3000 }] };
|
||||
}
|
||||
if (!config.tls) {
|
||||
console.log("TODO: tls: { modules: { name: 'acme', email: 'foo@bar.com', domains: [ '*' ] } }");
|
||||
config.tls = {
|
||||
agreeTos: args.agreeTos || args.agree || args['agree-tos']
|
||||
, servernames: (args.servernames||'').split(',').filter(Boolean).map(function (str) { return str.toLowerCase(); })
|
||||
};
|
||||
config.tls = {};
|
||||
}
|
||||
if (!config.tls.acme && (args.email || args.agreeTos)) {
|
||||
config.tls.acme = {};
|
||||
}
|
||||
if (typeof args.agreeTos === 'string') {
|
||||
config.tls.acme.approvedDomains = args.agreeTos.split(',');
|
||||
}
|
||||
if (args.email) {
|
||||
config.email = args.email;
|
||||
config.tls.email = args.email;
|
||||
config.tls.acme.email = args.email;
|
||||
}
|
||||
|
||||
// maybe this should not go in config... but be ephemeral in some way?
|
||||
|
@ -195,20 +198,20 @@ function readConfigAndRun(args) {
|
|||
|
||||
function readEnv(args) {
|
||||
// TODO
|
||||
try {
|
||||
if (process.env.GOLDILOCKS_HOME) {
|
||||
process.chdir(process.env.GOLDILOCKS_HOME);
|
||||
}
|
||||
} catch (err) {}
|
||||
|
||||
var env = {
|
||||
tunnel: process.env.GOLDILOCKS_TUNNEL_TOKEN || process.env.GOLDILOCKS_TUNNEL && true
|
||||
, email: process.env.GOLDILOCKS_EMAIL
|
||||
, cwd: process.env.GOLDILOCKS_HOME
|
||||
, cwd: process.env.GOLDILOCKS_HOME || process.cwd()
|
||||
, debug: process.env.GOLDILOCKS_DEBUG && true
|
||||
};
|
||||
args.cwd = args.cwd || env.cwd;
|
||||
Object.keys(env).forEach(function (key) {
|
||||
if ('undefined' === typeof args[key]) {
|
||||
args[key] = env[key];
|
||||
}
|
||||
});
|
||||
|
||||
readConfigAndRun(args);
|
||||
readConfigAndRun(Object.assign({}, env, args));
|
||||
}
|
||||
|
||||
var program = require('commander');
|
||||
|
@ -222,5 +225,4 @@ program
|
|||
.option('--debug', "Enable debug output")
|
||||
.parse(process.argv);
|
||||
|
||||
program.cwd = process.cwd();
|
||||
readEnv(program);
|
||||
|
|
Loading…
Reference in New Issue