Skip to content

Commit

Permalink
Support for JSON via HYDRA_SERVICE env var
Browse files Browse the repository at this point in the history
  • Loading branch information
cjus committed May 24, 2017
1 parent 4a07e1f commit 6683c32
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,12 @@ class Hydra extends EventEmitter {

let partialConfig = true;
if (process.env.HYDRA_SERVICE) {
let hydraService = process.env.HYDRA_SERVICE;
if (hydraService.includes('|')) {
let hydraService = process.env.HYDRA_SERVICE.trim();
if (hydraService[0] === '{') {
let newHydraBranch = Utils.safeJSONParse(hydraService);
Object.assign(config.hydra, newHydraBranch);
partialConfig = false;
} if (hydraService.includes('|')) {
hydraService = hydraService.replace(/(\r\n|\r|\n)/g, '');
let newHydraBranch = {};
let key = '';
Expand All @@ -172,7 +176,11 @@ class Hydra extends EventEmitter {
return;
}
if (config.hydra.serviceName.includes(':')) {
reject(new Error('Config can not have a colon character in its name'));
reject(new Error('serviceName can not have a colon character in its name'));
return;
}
if (config.hydra.serviceName.includes(' ')) {
reject(new Error('serviceName can not have a space character in its name'));
return;
}

Expand Down

0 comments on commit 6683c32

Please sign in to comment.