Skip to content

Commit

Permalink
fix: connect argv from config to command and test
Browse files Browse the repository at this point in the history
  • Loading branch information
saintsebastian committed Dec 10, 2017
1 parent 67d04a8 commit 66e696c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,19 @@ export class Program {
});
}

let argvFromConfig = { ...argv };
if (argv.config) {
const configFileName = path.resolve(argv.config);
const configObject = loadJSConfigFile(configFileName);
applyConfigToArgv({
argvFromConfig = applyConfigToArgv({
argv,
configFileName,
configObject,
options: this.options,
});
}

await runCommand(argv, {shouldExitProgram});
await runCommand(argvFromConfig, {shouldExitProgram});

} catch (error) {
if (!(error instanceof UsageError) || argv.verbose) {
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/test.program.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,16 @@ describe('program.main', () => {
prop: 'prop',
};
const resolvedFakePath = path.resolve(fakePath);
const expectedArgv = {
_: ['lint'],
config: fakePath,
};
const fakeLoadJSConfigFile = sinon.spy(() => {
return configObject;
});
const fakeApplyConfigToArgv = sinon.spy(() => {});
const fakeApplyConfigToArgv = sinon.spy(() => {
return expectedArgv;
});

return execProgram(
['lint', '--config', fakePath],
Expand Down

0 comments on commit 66e696c

Please sign in to comment.