Skip to content

Commit

Permalink
feat: basic implementation of command line config option
Browse files Browse the repository at this point in the history
  • Loading branch information
saintsebastian committed Sep 18, 2017
1 parent 79ba4e6 commit 5552269
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ export function loadJSConfigFile(filePath: string): Object {
'Did you set module.exports = {...}?');
}
return configObject;
}
}
22 changes: 22 additions & 0 deletions src/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {UsageError} from './errors';
import {createLogger, consoleStream as defaultLogStream} from './util/logger';
import {coerceCLICustomPreference} from './firefox/preferences';
import {checkForUpdates as defaultUpdateChecker} from './util/updates';
import {loadJSConfigFile, applyConfigToArgv} from './config';

const log = createLogger(__filename);
const envPrefix = 'WEB_EXT';
Expand Down Expand Up @@ -132,6 +133,20 @@ export class Program {
log.info('Version:', getVersion(absolutePackageDir));
}

if (argv.config) {
const configObject = loadJSConfigFile(argv.config);
try {
applyConfigToArgv({
argv,
configObject,
options: this.options,
configFileName: argv.config,
});
} catch (error) {
log.error(error.message);
}

}
try {
if (cmd === undefined) {
throw new UsageError('No sub-command was specified in the args');
Expand Down Expand Up @@ -265,6 +280,13 @@ Example: $0 --help run.
describe: 'Disable all features that require standard input',
type: 'boolean',
},
'config': {
alias: 'c',
describe: 'Location of the config file',
default: undefined,
requiresArg: true,
type: 'string',
},
});

program
Expand Down

0 comments on commit 5552269

Please sign in to comment.