[untested] searches root app dir for config.json /config.json /usergrid/config.json /config/usergrid.json
Project: http://git-wip-us.apache.org/repos/asf/usergrid-nodejs/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid-nodejs/commit/3ae94f52 Tree: http://git-wip-us.apache.org/repos/asf/usergrid-nodejs/tree/3ae94f52 Diff: http://git-wip-us.apache.org/repos/asf/usergrid-nodejs/diff/3ae94f52 Branch: refs/heads/master Commit: 3ae94f521b6f7f873ccba925d4911ed0af544ad1 Parents: e3e2c57 Author: brandon <[email protected]> Authored: Wed Feb 17 12:41:22 2016 -0800 Committer: brandon <[email protected]> Committed: Wed Feb 17 12:41:22 2016 -0800 ---------------------------------------------------------------------- helpers/config.js | 15 +++++++++++++-- package.json | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid-nodejs/blob/3ae94f52/helpers/config.js ---------------------------------------------------------------------- diff --git a/helpers/config.js b/helpers/config.js index 26c4fd2..63efdaa 100644 --- a/helpers/config.js +++ b/helpers/config.js @@ -1,7 +1,10 @@ 'use strict' var util = require('util'), - _ = require('lodash') + path = require('path'), + file = require("file"), + _ = require('lodash'), + appRoot = path.dirname(require.main.filename) if (/mocha$/i.test(process.argv[1])) { var target = _(_.last(process.argv)).startsWith('--target=') ? _.last(process.argv).replace(/--target=/, '') : '1.0' @@ -14,7 +17,15 @@ if (/mocha$/i.test(process.argv[1])) { module.exports = config } else { try { - module.exports = require('../config.json') + file.walkSync(appRoot, function(start, dirs, names) { + if (_.includes(dirs, "config") && _.includes(names, "usergrid.json")) { + module.exports = require(appRoot + '/config/usergrid.json') + } else if (_.includes(dirs, "usergrid") && _.includes(names, "config.json")) { + module.exports = require(appRoot + '/usergrid/config.json') + } else if (_.includes(names, "config.json")) { + module.exports = require(appRoot + '/config.json') + } + }) } catch (e) { } http://git-wip-us.apache.org/repos/asf/usergrid-nodejs/blob/3ae94f52/package.json ---------------------------------------------------------------------- diff --git a/package.json b/package.json index 4207d84..f930e1a 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "author": "Brandon Shelley", "dependencies": { "async": "latest", + "file": "latest", "file-type": "^3.4.0", "lodash": "~4.0", "lodash-inflection": "latest",
