|
1 |
| -import { Command, CommandScope, Option } from '../models/command'; |
2 |
| -import TestTask from '../tasks/test'; |
| 1 | +import { CommandScope, Option } from '../models/command'; |
| 2 | +import { ArchitectCommand } from '../models/architect-command'; |
3 | 3 |
|
4 |
| - |
5 |
| -export interface TestOptions { |
6 |
| - watch?: boolean; |
7 |
| - codeCoverage?: boolean; |
8 |
| - singleRun?: boolean; |
9 |
| - browsers?: string; |
10 |
| - colors?: boolean; |
11 |
| - log?: string; |
12 |
| - port?: number; |
13 |
| - reporters?: string; |
14 |
| - sourcemaps?: boolean; |
15 |
| - progress?: boolean; |
16 |
| - config: string; |
17 |
| - poll?: number; |
18 |
| - environment?: string; |
| 4 | +export interface Options { |
19 | 5 | app?: string;
|
20 |
| - preserveSymlinks?: boolean; |
| 6 | + configuration?: string; |
| 7 | + prod: boolean; |
21 | 8 | }
|
22 | 9 |
|
23 |
| -export default class TestCommand extends Command { |
| 10 | +export default class TestCommand extends ArchitectCommand { |
24 | 11 | public readonly name = 'test';
|
| 12 | + public readonly target = 'karma'; |
25 | 13 | public readonly description = 'Run unit tests in existing project.';
|
26 | 14 | public static aliases = ['t'];
|
27 | 15 | public readonly scope = CommandScope.inProject;
|
28 | 16 | public readonly arguments: string[] = [];
|
29 |
| - public readonly options: Option[] = []; |
| 17 | + public readonly options: Option[] = [ |
| 18 | + this.prodOption, |
| 19 | + this.configurationOption |
| 20 | + ]; |
30 | 21 |
|
31 |
| - public async run(options: TestOptions) { |
32 |
| - const testTask = new TestTask({ |
33 |
| - ui: this.ui, |
34 |
| - project: this.project |
| 22 | + public async run(options: Options) { |
| 23 | + let configuration = options.configuration; |
| 24 | + if (!configuration && options.prod) { |
| 25 | + configuration = 'production'; |
| 26 | + } |
| 27 | + const overrides = {...options}; |
| 28 | + delete overrides.app; |
| 29 | + delete overrides.prod; |
| 30 | + return this.runArchitect({ |
| 31 | + app: options.app, |
| 32 | + configuration, |
| 33 | + overrides |
35 | 34 | });
|
36 |
| - |
37 |
| - return await testTask.run(options); |
38 | 35 | }
|
39 | 36 | }
|
0 commit comments