From 5788abac1eede29d29c57a3c6c1c34e14aba8eed Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 5 Nov 2019 00:27:03 -0700 Subject: [PATCH] default to local basePath --- greenlock.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/greenlock.js b/greenlock.js index 0866f96..c3b573f 100644 --- a/greenlock.js +++ b/greenlock.js @@ -420,6 +420,15 @@ G.create = function(gconf) { // packageAgent, maintainerEmail return greenlock._acme(args).then(function(acme) { var storeConf = args.store || mconf.store; + storeConf = JSON.parse(JSON.stringify(storeConf)); + storeConf.packageRoot = gconf.packageRoot; + if (storeConf.basePath) { + var path = require('path'); + storeConf.basePath = path.resolve( + gconf.packageRoot || process.cwd(), + 'greenlock' + ); + } return P._loadStore(storeConf).then(function(store) { return A._getOrCreate( greenlock, @@ -493,20 +502,26 @@ function mergeDefaults(MCONF, gconf) { MCONF.subscriberEmail = gconf.subscriberEmail; } - var homedir; // Load the default store module if (!MCONF.store) { if (gconf.store) { MCONF.store = gconf.store; } else { - homedir = require('os').homedir(); MCONF.store = { - module: 'greenlock-store-fs', - basePath: homedir + '/.config/greenlock/' + module: 'greenlock-store-fs' }; } } + if ('greenlock-store-fs' === MCONF.store.module && !MCONF.store.basePath) { + //homedir = require('os').homedir(); + if (gconf.configFile) { + MCONF.store.basePath = gconf.configFile.replace(/\.json$/i, '.d'); + } else { + MCONF.store.basePath = './greenlock.d'; + } + } + // just to test that it loads P._loadSync(MCONF.store.module);