-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathrun-target-spec.ts
30 lines (26 loc) · 1.03 KB
/
run-target-spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { Path, experimental, logging, normalize } from '@angular-devkit/core';
import { Observable } from 'rxjs';
import { concatMap } from 'rxjs/operators';
import { Architect, BuildEvent, TargetSpecifier } from '../src';
import { TestProjectHost } from './test-project-host';
export function runTargetSpec(
host: TestProjectHost,
targetSpec: TargetSpecifier,
overrides = {},
logger: logging.Logger = new logging.NullLogger(),
): Observable<BuildEvent> {
targetSpec = { ...targetSpec, overrides };
const workspaceFile = normalize('angular.json');
const workspace = new experimental.workspace.Workspace(host.root(), host);
return workspace.loadWorkspaceFromHost(workspaceFile).pipe(
concatMap(ws => new Architect(ws).loadArchitect()),
concatMap(arch => arch.run(arch.getBuilderConfiguration(targetSpec), { logger })),
);
}