Skip to content

Commit

Permalink
feat(config): add array management for systems var ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Sep 26, 2019
1 parent 630cd0b commit 5e5ab52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ const initGlobalConfig = () => {
defaultConfig = require(path.join(process.cwd(), './config', 'defaults', 'development'));
}
// Get the config from process.env.WAOS_NODE_*
const environmentVars = _.mapKeys(
let environmentVars = _.mapKeys(
_.pickBy(process.env, (_value, key) => key.startsWith('WAOS_NODE_')),
(_v, k) => k.split('_').slice(2).join('.'),
);
// convert string array from sys to real array
environmentVars = _.mapValues(environmentVars, v => ((v[0] === '[' && v[v.length - 1] === ']') ? v.replace(/'/g, '').slice(1, -1).split(',') : v));
const environmentConfigVars = {};
_.forEach(environmentVars, (v, k) => objectPath.set(environmentConfigVars, k, v));
// Merge config files
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy-travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ssh -p $sshPort $sshUser@$sshHost -o StrictHostKeyChecking=no "$( cat <<EOT
git stash
git pull
npm i
WAOS_NODE_port='${depPort}' WAOS_NODE_cors='${depCors}' npm run prod
WAOS_NODE_port='${depPort}' WAOS_NODE_cors_origin='${depCors}' npm run prod
echo "$(date -u) Deploy ${depProject} on node $(node -v) with npm $(npm -v)" >> ./deploy.log
exit
EOT
Expand Down

0 comments on commit 5e5ab52

Please sign in to comment.