angular/packages/compiler-cli/ngcc/src/path_mappings.ts
Joey Perrott 6f829180f7 build: update license headers to reference Google LLC (#37205)
Update the license headers throughout the repository to reference Google LLC
rather than Google Inc, for the required license headers.

PR Close #37205
2020-05-26 14:27:01 -04:00

30 lines
910 B
TypeScript

/**
* @license
* Copyright Google LLC 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 {AbsoluteFsPath, resolve} from '../../src/ngtsc/file_system';
import {ParsedConfiguration} from '../../src/perform_compile';
export type PathMappings = {
baseUrl: string,
paths: {[key: string]: string[]}
};
/**
* If `pathMappings` is not provided directly, then try getting it from `tsConfig`, if available.
*/
export function getPathMappingsFromTsConfig(
tsConfig: ParsedConfiguration|null, projectPath: AbsoluteFsPath): PathMappings|undefined {
if (tsConfig !== null && tsConfig.options.baseUrl !== undefined &&
tsConfig.options.paths !== undefined) {
return {
baseUrl: resolve(projectPath, tsConfig.options.baseUrl),
paths: tsConfig.options.paths,
};
}
}