Skip to content

Commit

Permalink
Fix the search for ioc.config file
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagobustamante committed Mar 28, 2018
1 parent 8b5dae7 commit 3f0a352
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ const isBrowser = new Function('try {return this===window;}catch(e){return false

let useES6 = false;
if (!isBrowser()) {
const fs = require('fs');
useES6 = process.env.ES6 === 'true';
if (!useES6) {
const CONFIG_FILE = process.cwd() + '/ioc.config';
if (fs.existsSync(CONFIG_FILE)) {
const fs = require('fs');
const path = require('path');
const searchConfigFile = function() {
let configFile = path.join(__dirname, 'ioc.config');
const ROOT = path.join('/', 'ioc.config');
while (!fs.existsSync(configFile)) {
if (configFile === ROOT) {
return null;
}
configFile = path.normalize(path.join(path.dirname(configFile), '..', 'ioc.config'));
}
return configFile;
};

const CONFIG_FILE = searchConfigFile();
if (CONFIG_FILE && fs.existsSync(CONFIG_FILE)) {
const config = JSON.parse(fs.readFileSync(CONFIG_FILE));
if (config.es6) {
useES6 = true;
Expand Down

0 comments on commit 3f0a352

Please sign in to comment.