default to local basePath

This commit is contained in:
AJ ONeal 2019-11-05 00:27:03 -07:00
parent 7313167ca0
commit 5788abac1e
1 changed files with 19 additions and 4 deletions

View File

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