wip: more precise defaults

This commit is contained in:
AJ ONeal 2019-11-19 01:39:05 -07:00
parent 8e632aee63
commit a5d0cde282
4 changed files with 17 additions and 8 deletions

View File

@ -99,7 +99,7 @@ Flags.flags = function(mconf, myOpts) {
false,
'the module name or file path of the manager module to use',
'string',
'greenlock-manager-fs'
'@greenlock/manager'
],
'manager-xxxx': [
false,

View File

@ -425,7 +425,7 @@ G.create = function(gconf) {
var path = require('path');
if (!storeConf.basePath) {
storeConf.basePath = 'greenlock';
storeConf.basePath = gconf.configDir;
}
storeConf.basePath = path.resolve(
gconf.packageRoot || process.cwd(),
@ -511,6 +511,7 @@ function mergeDefaults(MCONF, gconf) {
}
}
/*
if ('greenlock-store-fs' === MCONF.store.module && !MCONF.store.basePath) {
//homedir = require('os').homedir();
if (gconf.configFile) {
@ -519,6 +520,7 @@ function mergeDefaults(MCONF, gconf) {
MCONF.store.basePath = './greenlock.d';
}
}
*/
// just to test that it loads
P._loadSync(MCONF.store.module);

View File

@ -125,10 +125,10 @@ Init._init = function(opts) {
}
//var mkdirp = promisify(require("@root/mkdirp"));
var configFile = path.join(opts.configDir, 'config.json');
opts.configFile = path.join(opts.configDir, 'config.json');
var config;
try {
config = JSON.parse(fs.readFileSync(configFile));
config = JSON.parse(fs.readFileSync(opts.configFile));
} catch (e) {
if ('ENOENT' !== e.code) {
throw e;

View File

@ -24,6 +24,8 @@ Rc._initSync = function(dirname, manager, configDir) {
rc = {};
}
var changed = true;
// In the general case the manager should be specified in the
// config file, which is in the config dir, but for the specific
// 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.module !== manager.module
) {
changed = true;
console.info(
"changing `manager` from '%s' to '%s'",
rc.manager,
manager
rc.manager.module || rc.manager,
manager.module || manager
);
}
}
@ -57,11 +60,15 @@ Rc._initSync = function(dirname, manager, configDir) {
configDir
);
}
changed = true;
rc.configDir = configDir;
fs.writeFileSync(rcpath, JSON.stringify(rc));
} else if (!rc.configDir) {
configDir = path.resolve(dirname, 'greenlock.d');
changed = true;
configDir = './greenlock.d';
rc.configDir = configDir;
}
if (changed) {
fs.writeFileSync(rcpath, JSON.stringify(rc));
}