Selaa lähdekoodia

fix: config env vars parsing

NGPixel 8 vuotta sitten
vanhempi
sitoutus
59ce39f033
4 muutettua tiedostoa jossa 6 lisäystä ja 16 poistoa
  1. 1 1
      npm/configs/config.heroku.yml
  2. 1 1
      npm/package.json
  3. 1 1
      server/helpers/config.js
  4. 3 13
      server/libs/config.js

+ 1 - 1
npm/configs/config.heroku.yml

@@ -103,7 +103,7 @@ sessionSecret: 1234567890abcdefghijklmnopqrstuvxyz
 # Database Connection String
 # ---------------------------------------------------------------------
 
-db: $(MONGO_URI)
+db: $(MONGODB_URI)
 
 # ---------------------------------------------------------------------
 # Git Connection Info

+ 1 - 1
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": {

+ 1 - 1
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] })
     )
   }

+ 3 - 13
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'))