Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): allow argv to be overridden in bootstrap #621

Merged
merged 1 commit into from
Apr 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cli/commitizen.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export {
* This is the main cli entry point.
* environment may be used for debugging.
*/
function bootstrap (environment = {}) {
function bootstrap (environment = {}, argv = process.argv) {

// Get cli args
let rawGitArgs = process.argv.slice(2, process.argv.length);
let rawGitArgs = argv.slice(2, argv.length);

// Parse the args
let parsedArgs = parse(rawGitArgs);
Expand Down
4 changes: 2 additions & 2 deletions src/cli/git-cz.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export {
* This is the main cli entry point.
* environment may be used for debugging.
*/
function bootstrap (environment = {}) {
function bootstrap (environment = {}, argv = process.argv) {

// Get cli args
let rawGitArgs = process.argv.slice(2, process.argv.length);
let rawGitArgs = argv.slice(2, argv.length);

let adapterConfig = environment.config || configLoader.load();

Expand Down
7 changes: 7 additions & 0 deletions test/tests/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,12 @@ describe('git-cz', () => {
});
});
});

describe('when argv is overridden', () => {
it('uses the overridden argv', () => {
bootstrap({}, ['node', 'git-cz', 'index.js']);
expect(fakeStrategies.git.args[0][0][0]).to.equal('index.js');
});
})
});
});