Supply config path to main.js and oputil.js, rather than specific config file

This commit is contained in:
David Stephens 2017-11-25 22:45:19 +00:00
parent 32557975d9
commit 521e38d7e9
4 changed files with 11 additions and 8 deletions

View File

@ -29,11 +29,12 @@ const ENIGMA_COPYRIGHT = 'ENiGMA½ Copyright (c) 2014-2017 Bryan Ashby';
const HELP =
`${ENIGMA_COPYRIGHT}
usage: main.js <args>
eg : main.js --config /enigma_install_path/config/
valid args:
--version : display version
--help : displays this help
--config PATH : override default config.hjson path
--config PATH : override default config path
`;
function printHelpAndExit() {
@ -56,7 +57,8 @@ function main() {
return callback(null, configOverridePath || conf.getDefaultPath(), _.isString(configOverridePath));
},
function initConfig(configPath, configPathSupplied, callback) {
conf.init(resolvePath(configPath), function configInit(err) {
const configFile = configPath + 'config.hjson';
conf.init(resolvePath(configFile), function configInit(err) {
//
// If the user supplied a path and we can't read/parse it
@ -65,7 +67,7 @@ function main() {
if(err) {
if('ENOENT' === err.code) {
if(configPathSupplied) {
console.error('Configuration file does not exist: ' + configPath);
console.error('Configuration file does not exist: ' + configFile);
} else {
configPathSupplied = null; // make non-fatal; we'll go with defaults
}

View File

@ -111,8 +111,8 @@ function init(configPath, options, cb) {
}
function getDefaultPath() {
// e.g. /enigma-bbs-install-path/config/config.hjson
return './config/config.hjson';
// e.g. /enigma-bbs-install-path/config/
return './config/';
}
function getDefaultConfig() {

View File

@ -7,7 +7,7 @@ const paths = require('path');
exports.getFullConfig = getFullConfig;
function getFullConfig(filePath, cb) {
// |filePath| is assumed to be in 'mods' if it's only a file name
// |filePath| is assumed to be in the config path if it's only a file name
if('.' === paths.dirname(filePath)) {
filePath = paths.join(Config.paths.config, filePath);
}

View File

@ -45,11 +45,12 @@ function printUsageAndSetExitCode(errMsg, exitCode) {
}
function getDefaultConfigPath() {
return './config/config.hjson';
return './config/';
}
function getConfigPath() {
return argv.config ? argv.config : config.getDefaultPath();
const baseConfigPath = argv.config ? argv.config : config.getDefaultPath();
return baseConfigPath + 'config.hjson';
}
function initConfig(cb) {