Split checking for config file location into helper file.
authorJack Allnutt <jack@allnutt.eu>
Mon, 24 Nov 2014 15:39:47 +0000 (15:39 +0000)
committerJack Allnutt <jack@allnutt.eu>
Mon, 24 Nov 2014 15:39:47 +0000 (15:39 +0000)
server/build.js
server/kiwi.js

index 22ecf79bd8d341b1f213b82a494e95cc3a979106..040e97917e25b9a2ee25a5518a5597a734f71999 100644 (file)
@@ -36,21 +36,10 @@ function concat(file_list, callback) {
 \r
 \r
 \r
-// Load the config, using -c argument if available\r
-(function (argv) {\r
-    var conf_switch = argv.indexOf('-c');\r
-    if (conf_switch !== -1) {\r
-        if (argv[conf_switch + 1]) {\r
-            return config.loadConfig(argv[conf_switch + 1]);\r
-        }\r
-    }\r
-\r
-    config.loadConfig();\r
-\r
-})(process.argv);\r
-\r
-\r
-\r
+if (!require('./helpers/configloader.js')()) {\r
+    console.error('Couldn\'t find a valid config.js file (Did you copy the config.example.js file yet?)');\r
+    process.exit(1);\r
+}\r
 \r
 var source_files = [\r
     global.config.public_http + '/src/app.js',\r
index 58df8106a84b64f3c9f39b172137cdd33d372dff..67e952bebd3585b21f001d5beed760fd0229e9f2 100755 (executable)
@@ -16,18 +16,8 @@ process.chdir(__dirname + '/../');
 // Get our own version from package.json
 global.build_version = require('../package.json').version;
 
-// Load the config, using -c argument if available
-(function (argv) {
-    var conf_switch = argv.indexOf('-c');
-    if (conf_switch !== -1) {
-        if (argv[conf_switch + 1]) {
-            return config.loadConfig(argv[conf_switch + 1]);
-        }
-    }
-
-    config.loadConfig();
-
-})(process.argv);
+// Load the configuration
+require('./helpers/configloader.js')();
 
 
 // If we're not running in the forground and we have a log file.. switch