1 | ;
|
2 | /**
|
3 | * @license
|
4 | * Copyright Google LLC All Rights Reserved.
|
5 | *
|
6 | * Use of this source code is governed by an MIT-style license that can be
|
7 | * found in the LICENSE file at https://angular.io/license
|
8 | */
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | exports.readTsconfig = void 0;
|
11 | const path = require("path");
|
12 | /**
|
13 | * Reads and parses a given TsConfig file.
|
14 | *
|
15 | * @param tsconfigPath - An absolute or relative path from 'workspaceRoot' of the tsconfig file.
|
16 | * @param workspaceRoot - workspaceRoot root location when provided
|
17 | * it will resolve 'tsconfigPath' from this path.
|
18 | */
|
19 | function readTsconfig(tsconfigPath, workspaceRoot) {
|
20 | const tsConfigFullPath = workspaceRoot ? path.resolve(workspaceRoot, tsconfigPath) : tsconfigPath;
|
21 | // We use 'ng' instead of 'ts' here because 'ts' is not aware of 'angularCompilerOptions'
|
22 | // and will not merged them if they are at un upper level tsconfig file when using `extends`.
|
23 | const ng = require('@angular/compiler-cli');
|
24 | const configResult = ng.readConfiguration(tsConfigFullPath);
|
25 | if (configResult.errors && configResult.errors.length) {
|
26 | throw new Error(ng.formatDiagnostics(configResult.errors));
|
27 | }
|
28 | return configResult;
|
29 | }
|
30 | exports.readTsconfig = readTsconfig;
|