wip: more precise defaults
This commit is contained in:
parent
8e632aee63
commit
a5d0cde282
|
@ -99,7 +99,7 @@ Flags.flags = function(mconf, myOpts) {
|
||||||
false,
|
false,
|
||||||
'the module name or file path of the manager module to use',
|
'the module name or file path of the manager module to use',
|
||||||
'string',
|
'string',
|
||||||
'greenlock-manager-fs'
|
'@greenlock/manager'
|
||||||
],
|
],
|
||||||
'manager-xxxx': [
|
'manager-xxxx': [
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -425,7 +425,7 @@ G.create = function(gconf) {
|
||||||
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
if (!storeConf.basePath) {
|
if (!storeConf.basePath) {
|
||||||
storeConf.basePath = 'greenlock';
|
storeConf.basePath = gconf.configDir;
|
||||||
}
|
}
|
||||||
storeConf.basePath = path.resolve(
|
storeConf.basePath = path.resolve(
|
||||||
gconf.packageRoot || process.cwd(),
|
gconf.packageRoot || process.cwd(),
|
||||||
|
@ -511,6 +511,7 @@ function mergeDefaults(MCONF, gconf) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if ('greenlock-store-fs' === MCONF.store.module && !MCONF.store.basePath) {
|
if ('greenlock-store-fs' === MCONF.store.module && !MCONF.store.basePath) {
|
||||||
//homedir = require('os').homedir();
|
//homedir = require('os').homedir();
|
||||||
if (gconf.configFile) {
|
if (gconf.configFile) {
|
||||||
|
@ -519,6 +520,7 @@ function mergeDefaults(MCONF, gconf) {
|
||||||
MCONF.store.basePath = './greenlock.d';
|
MCONF.store.basePath = './greenlock.d';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// just to test that it loads
|
// just to test that it loads
|
||||||
P._loadSync(MCONF.store.module);
|
P._loadSync(MCONF.store.module);
|
||||||
|
|
|
@ -125,10 +125,10 @@ Init._init = function(opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//var mkdirp = promisify(require("@root/mkdirp"));
|
//var mkdirp = promisify(require("@root/mkdirp"));
|
||||||
var configFile = path.join(opts.configDir, 'config.json');
|
opts.configFile = path.join(opts.configDir, 'config.json');
|
||||||
var config;
|
var config;
|
||||||
try {
|
try {
|
||||||
config = JSON.parse(fs.readFileSync(configFile));
|
config = JSON.parse(fs.readFileSync(opts.configFile));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if ('ENOENT' !== e.code) {
|
if ('ENOENT' !== e.code) {
|
||||||
throw e;
|
throw e;
|
||||||
|
|
15
lib/rc.js
15
lib/rc.js
|
@ -24,6 +24,8 @@ Rc._initSync = function(dirname, manager, configDir) {
|
||||||
rc = {};
|
rc = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var changed = true;
|
||||||
|
|
||||||
// In the general case the manager should be specified in the
|
// In the general case the manager should be specified in the
|
||||||
// config file, which is in the config dir, but for the specific
|
// config file, which is in the config dir, but for the specific
|
||||||
// case in which all custom plugins are being used and no config
|
// case in which all custom plugins are being used and no config
|
||||||
|
@ -35,10 +37,11 @@ Rc._initSync = function(dirname, manager, configDir) {
|
||||||
rc.manager !== manager ||
|
rc.manager !== manager ||
|
||||||
rc.manager.module !== manager.module
|
rc.manager.module !== manager.module
|
||||||
) {
|
) {
|
||||||
|
changed = true;
|
||||||
console.info(
|
console.info(
|
||||||
"changing `manager` from '%s' to '%s'",
|
"changing `manager` from '%s' to '%s'",
|
||||||
rc.manager,
|
rc.manager.module || rc.manager,
|
||||||
manager
|
manager.module || manager
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,11 +60,15 @@ Rc._initSync = function(dirname, manager, configDir) {
|
||||||
configDir
|
configDir
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
changed = true;
|
||||||
rc.configDir = configDir;
|
rc.configDir = configDir;
|
||||||
fs.writeFileSync(rcpath, JSON.stringify(rc));
|
|
||||||
} else if (!rc.configDir) {
|
} else if (!rc.configDir) {
|
||||||
configDir = path.resolve(dirname, 'greenlock.d');
|
changed = true;
|
||||||
|
configDir = './greenlock.d';
|
||||||
rc.configDir = configDir;
|
rc.configDir = configDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
fs.writeFileSync(rcpath, JSON.stringify(rc));
|
fs.writeFileSync(rcpath, JSON.stringify(rc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue