diff --git a/bin/lib/flags.js b/bin/lib/flags.js index 0c269c5..304f146 100644 --- a/bin/lib/flags.js +++ b/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, diff --git a/greenlock.js b/greenlock.js index 3fb19d2..cde06a0 100644 --- a/greenlock.js +++ b/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); diff --git a/lib/init.js b/lib/init.js index 2a015c6..28f4319 100644 --- a/lib/init.js +++ b/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; diff --git a/lib/rc.js b/lib/rc.js index 54adceb..38b9f1e 100644 --- a/lib/rc.js +++ b/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)); }