From 59ce39f0336ef6e031b9375af45f5291a1103ce3 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sun, 14 May 2017 21:20:40 -0400 Subject: [PATCH] fix: config env vars parsing --- npm/configs/config.heroku.yml | 2 +- npm/package.json | 2 +- server/helpers/config.js | 2 +- server/libs/config.js | 16 +++------------- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/npm/configs/config.heroku.yml b/npm/configs/config.heroku.yml index 72fd087d..32caa049 100644 --- a/npm/configs/config.heroku.yml +++ b/npm/configs/config.heroku.yml @@ -103,7 +103,7 @@ sessionSecret: 1234567890abcdefghijklmnopqrstuvxyz # Database Connection String # --------------------------------------------------------------------- -db: $(MONGO_URI) +db: $(MONGODB_URI) # --------------------------------------------------------------------- # Git Connection Info diff --git a/npm/package.json b/npm/package.json index fd118262..aa8650af 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "wiki.js", - "version": "1.0.0-beta.12", + "version": "1.0.0-beta.12.1", "description": "A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown", "main": "install.js", "scripts": { diff --git a/server/helpers/config.js b/server/helpers/config.js index 4104f5ac..8c1eddf4 100644 --- a/server/helpers/config.js +++ b/server/helpers/config.js @@ -12,7 +12,7 @@ module.exports = { parseConfigValue (cfg) { return _.replace( cfg, - (/\$\([A-Z0-9_]+\)/g, + (/\$\(([A-Z0-9_]+)\)/g, (m) => { return process.env[m] }) ) } diff --git a/server/libs/config.js b/server/libs/config.js index 482a8d5c..ef9c8dfa 100644 --- a/server/libs/config.js +++ b/server/libs/config.js @@ -4,15 +4,7 @@ const fs = require('fs') const yaml = require('js-yaml') const _ = require('lodash') const path = require('path') - -const deepMap = (obj, iterator, context) => { - return _.transform(obj, (result, val, key) => { - result[key] = _.isObject(val) - ? deepMap(val, iterator, context) - : iterator.call(context, val, key, obj) - }) -} -_.mixin({ deepMap }) +const cfgHelper = require('../helpers/config') /** * Load Application Configuration @@ -32,10 +24,8 @@ module.exports = (confPaths) => { try { appconfig = yaml.safeLoad( - _.replace( - fs.readFileSync(confPaths.config, 'utf8'), - (/\$\([A-Z0-9_]+\)/g, - (m) => { return process.env[m] }) + cfgHelper.parseConfigValue( + fs.readFileSync(confPaths.config, 'utf8') ) ) appdata = yaml.safeLoad(fs.readFileSync(confPaths.data, 'utf8'))