Skip to content

Commit

Permalink
not parsing argv after --
Browse files Browse the repository at this point in the history
  • Loading branch information
tharvik committed Oct 2, 2019
1 parent f0c0d7d commit 6c14ba2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ function parseOptions(argv) {
seed,
workerCount;

argv.forEach(function(arg) {
for (var i in argv) {
var arg = argv[i];
if (arg === '--no-color') {
color = false;
} else if (arg === '--color') {
Expand All @@ -103,12 +104,14 @@ function parseOptions(argv) {
configPath = arg.match("^--config=(.*)")[1];
} else if (arg.match("^--reporter=")) {
reporter = arg.match("^--reporter=(.*)")[1];
} else if (arg === '--') {
break;
} else if (isFileArg(arg)) {
files.push(arg);
} else if (!isEnvironmentVariable(arg)) {
unknownOptions.push(arg);
}
});
}
return {
color: color,
configPath: configPath,
Expand Down Expand Up @@ -180,7 +183,7 @@ function installExamples(options) {

function help(options) {
var print = options.print;
print('Usage: jasmine [command] [options] [files]');
print('Usage: jasmine [command] [options] [files] [--]');
print('');
print('Commands:');
Object.keys(subCommands).forEach(function(cmd) {
Expand All @@ -206,6 +209,7 @@ function help(options) {
print('%s\tpath to your optional jasmine.json', lPad('--config=', 18));
print('%s\tpath to reporter to use instead of the default Jasmine reporter', lPad('--reporter=', 18));
print('%s\tnumber of workers to run the tests in parallel. Default is 1', lPad('--worker-count=', 18));
print('%s\tmarker to signal the end of options meant for Jasmine', lPad('--', 18));
print('');
print('The given arguments take precedence over options in your jasmine.json');
print('The path to your optional jasmine.json can also be configured by setting the JASMINE_CONFIG_PATH environment variable');
Expand Down
8 changes: 8 additions & 0 deletions spec/command_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ describe('command', function() {
});
});

describe('--', function() {
it('skips anything after it', function() {
this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', '--', '--no-color']);
expect(this.out.getOutput()).toBe('');
expect(this.fakeJasmine.showColors).toHaveBeenCalledWith(true);
});
});

describe('examples', function() {
beforeEach(function() {
this.command.run(this.fakeJasmine, ['node', 'bin/jasmine.js', 'examples']);
Expand Down

0 comments on commit 6c14ba2

Please sign in to comment.