forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnormalize-karma-schema.ts
More file actions
52 lines (45 loc) · 1.71 KB
/
normalize-karma-schema.ts
File metadata and controls
52 lines (45 loc) · 1.71 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @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, virtualFs } from '@angular-devkit/core';
import { AssetPatternClass, OptimizationClass, SourceMapClass } from '../browser/schema';
import { KarmaBuilderSchema } from '../karma/schema';
import { normalizeAssetPatterns } from './normalize-asset-patterns';
import {
NormalizedFileReplacement,
normalizeFileReplacements,
} from './normalize-file-replacements';
import { normalizeOptimization } from './normalize-optimization';
import { normalizeSourceMaps } from './normalize-source-maps';
/**
* A normalized webpack server builder schema.
*/
export interface NormalizedKarmaBuilderSchema extends KarmaBuilderSchema {
sourceMap: SourceMapClass;
fileReplacements: NormalizedFileReplacement[];
assets: AssetPatternClass[];
optimization: OptimizationClass;
}
export function normalizeKarmaSchema(
host: virtualFs.Host<{}>,
root: Path,
projectRoot: Path,
sourceRoot: Path | undefined,
options: KarmaBuilderSchema,
): NormalizedKarmaBuilderSchema {
const syncHost = new virtualFs.SyncDelegateHost(host);
const normalizedSourceMapOptions = normalizeSourceMaps(options.sourceMap);
normalizedSourceMapOptions.vendor =
normalizedSourceMapOptions.vendor || options.vendorSourceMap || false;
return {
...options,
fileReplacements: normalizeFileReplacements(options.fileReplacements, syncHost, root),
assets: normalizeAssetPatterns(options.assets || [], syncHost, root, projectRoot, sourceRoot),
sourceMap: normalizedSourceMapOptions,
optimization: normalizeOptimization(undefined),
};
}