Supply config path to main.js and oputil.js, rather than specific config file
This commit is contained in:
parent
32557975d9
commit
521e38d7e9
|
@ -29,11 +29,12 @@ const ENIGMA_COPYRIGHT = 'ENiGMA½ Copyright (c) 2014-2017 Bryan Ashby';
|
||||||
const HELP =
|
const HELP =
|
||||||
`${ENIGMA_COPYRIGHT}
|
`${ENIGMA_COPYRIGHT}
|
||||||
usage: main.js <args>
|
usage: main.js <args>
|
||||||
|
eg : main.js --config /enigma_install_path/config/
|
||||||
|
|
||||||
valid args:
|
valid args:
|
||||||
--version : display version
|
--version : display version
|
||||||
--help : displays this help
|
--help : displays this help
|
||||||
--config PATH : override default config.hjson path
|
--config PATH : override default config path
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function printHelpAndExit() {
|
function printHelpAndExit() {
|
||||||
|
@ -56,7 +57,8 @@ function main() {
|
||||||
return callback(null, configOverridePath || conf.getDefaultPath(), _.isString(configOverridePath));
|
return callback(null, configOverridePath || conf.getDefaultPath(), _.isString(configOverridePath));
|
||||||
},
|
},
|
||||||
function initConfig(configPath, configPathSupplied, callback) {
|
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
|
// If the user supplied a path and we can't read/parse it
|
||||||
|
@ -65,7 +67,7 @@ function main() {
|
||||||
if(err) {
|
if(err) {
|
||||||
if('ENOENT' === err.code) {
|
if('ENOENT' === err.code) {
|
||||||
if(configPathSupplied) {
|
if(configPathSupplied) {
|
||||||
console.error('Configuration file does not exist: ' + configPath);
|
console.error('Configuration file does not exist: ' + configFile);
|
||||||
} else {
|
} else {
|
||||||
configPathSupplied = null; // make non-fatal; we'll go with defaults
|
configPathSupplied = null; // make non-fatal; we'll go with defaults
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,8 @@ function init(configPath, options, cb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultPath() {
|
function getDefaultPath() {
|
||||||
// e.g. /enigma-bbs-install-path/config/config.hjson
|
// e.g. /enigma-bbs-install-path/config/
|
||||||
return './config/config.hjson';
|
return './config/';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultConfig() {
|
function getDefaultConfig() {
|
||||||
|
|
|
@ -7,7 +7,7 @@ const paths = require('path');
|
||||||
exports.getFullConfig = getFullConfig;
|
exports.getFullConfig = getFullConfig;
|
||||||
|
|
||||||
function getFullConfig(filePath, cb) {
|
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)) {
|
if('.' === paths.dirname(filePath)) {
|
||||||
filePath = paths.join(Config.paths.config, filePath);
|
filePath = paths.join(Config.paths.config, filePath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,11 +45,12 @@ function printUsageAndSetExitCode(errMsg, exitCode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultConfigPath() {
|
function getDefaultConfigPath() {
|
||||||
return './config/config.hjson';
|
return './config/';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConfigPath() {
|
function getConfigPath() {
|
||||||
return argv.config ? argv.config : config.getDefaultPath();
|
const baseConfigPath = argv.config ? argv.config : config.getDefaultPath();
|
||||||
|
return baseConfigPath + 'config.hjson';
|
||||||
}
|
}
|
||||||
|
|
||||||
function initConfig(cb) {
|
function initConfig(cb) {
|
||||||
|
|
Loading…
Reference in New Issue