Skip to content

Commit

Permalink
Misc refactoring in command.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sgravrock committed Jul 2, 2022
1 parent b3f76a8 commit 0115194
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Command(projectBaseDir, examplesDir, print) {
print('');
help({print: print});
} else {
await runJasmine(jasmine, env, print);
await runJasmine(jasmine, env);
}
}
};
Expand All @@ -76,8 +76,7 @@ function parseOptions(argv) {
random,
seed;

for (let i in argv) {
const arg = argv[i];
for (const arg of argv) {
if (arg === '--no-color') {
color = false;
} else if (arg === '--color') {
Expand Down Expand Up @@ -106,55 +105,56 @@ function parseOptions(argv) {
unknownOptions.push(arg);
}
}

return {
color: color,
configPath: configPath,
filter: filter,
failFast: failFast,
helpers: helpers,
requires: requires,
reporter: reporter,
files: files,
random: random,
seed: seed,
unknownOptions: unknownOptions
color,
configPath,
filter,
failFast,
helpers,
requires,
reporter,
files,
random,
seed,
unknownOptions
};
}

async function runJasmine(jasmine, env, print) {
await jasmine.loadConfigFile(env.configPath || process.env.JASMINE_CONFIG_PATH);
async function runJasmine(jasmine, options) {
await jasmine.loadConfigFile(options.configPath || process.env.JASMINE_CONFIG_PATH);

if (env.failFast !== undefined) {
if (options.failFast !== undefined) {
jasmine.env.configure({
stopSpecOnExpectationFailure: env.failFast,
stopOnSpecFailure: env.failFast
stopSpecOnExpectationFailure: options.failFast,
stopOnSpecFailure: options.failFast
});
}

if (env.seed !== undefined) {
jasmine.seed(env.seed);
if (options.seed !== undefined) {
jasmine.seed(options.seed);
}

if (env.random !== undefined) {
jasmine.randomizeTests(env.random);
if (options.random !== undefined) {
jasmine.randomizeTests(options.random);
}

if (env.helpers !== undefined && env.helpers.length) {
jasmine.addMatchingHelperFiles(env.helpers);
if (options.helpers !== undefined && options.helpers.length) {
jasmine.addMatchingHelperFiles(options.helpers);
}

if (env.requires !== undefined && env.requires.length) {
jasmine.addRequires(env.requires);
if (options.requires !== undefined && options.requires.length) {
jasmine.addRequires(options.requires);
}

if (env.reporter !== undefined) {
await registerReporter(env.reporter, jasmine);
if (options.reporter !== undefined) {
await registerReporter(options.reporter, jasmine);
}

jasmine.showColors(env.color);
jasmine.showColors(options.color);

try {
await jasmine.execute(env.files, env.filter);
await jasmine.execute(options.files, options.filter);
} catch (error) {
console.error(error);
process.exit(1);
Expand Down

0 comments on commit 0115194

Please sign in to comment.