Skip to content

Commit 0115194

Browse files
committed
Misc refactoring in command.js
1 parent b3f76a8 commit 0115194

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

lib/command.js

+31-31
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function Command(projectBaseDir, examplesDir, print) {
5353
print('');
5454
help({print: print});
5555
} else {
56-
await runJasmine(jasmine, env, print);
56+
await runJasmine(jasmine, env);
5757
}
5858
}
5959
};
@@ -76,8 +76,7 @@ function parseOptions(argv) {
7676
random,
7777
seed;
7878

79-
for (let i in argv) {
80-
const arg = argv[i];
79+
for (const arg of argv) {
8180
if (arg === '--no-color') {
8281
color = false;
8382
} else if (arg === '--color') {
@@ -106,55 +105,56 @@ function parseOptions(argv) {
106105
unknownOptions.push(arg);
107106
}
108107
}
108+
109109
return {
110-
color: color,
111-
configPath: configPath,
112-
filter: filter,
113-
failFast: failFast,
114-
helpers: helpers,
115-
requires: requires,
116-
reporter: reporter,
117-
files: files,
118-
random: random,
119-
seed: seed,
120-
unknownOptions: unknownOptions
110+
color,
111+
configPath,
112+
filter,
113+
failFast,
114+
helpers,
115+
requires,
116+
reporter,
117+
files,
118+
random,
119+
seed,
120+
unknownOptions
121121
};
122122
}
123123

124-
async function runJasmine(jasmine, env, print) {
125-
await jasmine.loadConfigFile(env.configPath || process.env.JASMINE_CONFIG_PATH);
124+
async function runJasmine(jasmine, options) {
125+
await jasmine.loadConfigFile(options.configPath || process.env.JASMINE_CONFIG_PATH);
126126

127-
if (env.failFast !== undefined) {
127+
if (options.failFast !== undefined) {
128128
jasmine.env.configure({
129-
stopSpecOnExpectationFailure: env.failFast,
130-
stopOnSpecFailure: env.failFast
129+
stopSpecOnExpectationFailure: options.failFast,
130+
stopOnSpecFailure: options.failFast
131131
});
132132
}
133133

134-
if (env.seed !== undefined) {
135-
jasmine.seed(env.seed);
134+
if (options.seed !== undefined) {
135+
jasmine.seed(options.seed);
136136
}
137137

138-
if (env.random !== undefined) {
139-
jasmine.randomizeTests(env.random);
138+
if (options.random !== undefined) {
139+
jasmine.randomizeTests(options.random);
140140
}
141141

142-
if (env.helpers !== undefined && env.helpers.length) {
143-
jasmine.addMatchingHelperFiles(env.helpers);
142+
if (options.helpers !== undefined && options.helpers.length) {
143+
jasmine.addMatchingHelperFiles(options.helpers);
144144
}
145145

146-
if (env.requires !== undefined && env.requires.length) {
147-
jasmine.addRequires(env.requires);
146+
if (options.requires !== undefined && options.requires.length) {
147+
jasmine.addRequires(options.requires);
148148
}
149149

150-
if (env.reporter !== undefined) {
151-
await registerReporter(env.reporter, jasmine);
150+
if (options.reporter !== undefined) {
151+
await registerReporter(options.reporter, jasmine);
152152
}
153153

154-
jasmine.showColors(env.color);
154+
jasmine.showColors(options.color);
155155

156156
try {
157-
await jasmine.execute(env.files, env.filter);
157+
await jasmine.execute(options.files, options.filter);
158158
} catch (error) {
159159
console.error(error);
160160
process.exit(1);

0 commit comments

Comments
 (0)