Browse Source

wip: more precise defaults

v4
AJ ONeal 4 years ago
parent
commit
a5d0cde282
  1. 2
      bin/lib/flags.js
  2. 4
      greenlock.js
  3. 4
      lib/init.js
  4. 15
      lib/rc.js

2
bin/lib/flags.js

@ -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,

4
greenlock.js

@ -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);

4
lib/init.js

@ -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;

15
lib/rc.js

@ -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));
}

Loading…
Cancel
Save