Better method for searching for config file
diff --git a/helpers/config.js b/helpers/config.js
index 63efdaa..1de27e7 100644
--- a/helpers/config.js
+++ b/helpers/config.js
@@ -18,15 +18,21 @@
} else {
try {
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')
+ if (_.includes(names, "config.json") || _.includes(names, "usergrid.json")) {
+ var name = _.first(names.filter(function(name) {
+ return name == "config.json" || name == "usergrid.json"
+ }).sort().reverse())
+ var configPath = util.format("%s/%s", start, name)
+ module.exports = require(configPath)
+ if (module.exports.orgId === undefined || module.exports.appId === undefined) {
+ console.log(util.format("Config file '%s' is not a valid Usergrid configuration file", configPath))
+ module.exports = {}
+ } else {
+ console.log(util.format("Using config file '%s'", configPath))
+ }
}
})
} catch (e) {
-
+
}
}
\ No newline at end of file