6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { normalize } from '@angular-devkit/core' ;
10
- import {
11
- ProjectDefinition ,
12
- WorkspaceDefinition ,
13
- WorkspaceHost ,
14
- } from '@angular-devkit/core/src/workspace' ;
15
- import { readJsonWorkspace } from '@angular-devkit/core/src/workspace/json/reader' ;
9
+ import { normalize , workspaces } from '@angular-devkit/core' ;
16
10
import { Tree } from '@angular-devkit/schematics' ;
11
+ import { getWorkspace } from '@schematics/angular/utility/workspace' ;
17
12
import { WorkspacePath } from '../update-tool/file-system' ;
18
13
19
14
/** Name of the default Angular CLI workspace configuration files. */
20
15
const defaultWorkspaceConfigPaths = [ '/angular.json' , '/.angular.json' ] ;
21
16
22
17
/** Gets the tsconfig path from the given target within the specified project. */
23
18
export function getTargetTsconfigPath (
24
- project : ProjectDefinition ,
19
+ project : workspaces . ProjectDefinition ,
25
20
targetName : string ,
26
21
) : WorkspacePath | null {
27
22
const tsconfig = project . targets ?. get ( targetName ) ?. options ?. tsConfig ;
@@ -31,18 +26,15 @@ export function getTargetTsconfigPath(
31
26
/** Resolve the workspace configuration of the specified tree gracefully. */
32
27
export async function getWorkspaceConfigGracefully (
33
28
tree : Tree ,
34
- ) : Promise < WorkspaceDefinition | null > {
29
+ ) : Promise < workspaces . WorkspaceDefinition | null > {
35
30
const path = defaultWorkspaceConfigPaths . find ( filePath => tree . exists ( filePath ) ) ;
36
- const configBuffer = tree . read ( path ! ) ;
37
31
38
- if ( ! path || ! configBuffer ) {
32
+ if ( ! path ) {
39
33
return null ;
40
34
}
41
35
42
36
try {
43
- return await readJsonWorkspace ( path , {
44
- readFile : async filePath => tree . read ( filePath ) ! . toString ( ) ,
45
- } as WorkspaceHost ) ;
37
+ return getWorkspace ( tree , path ) ;
46
38
} catch {
47
39
return null ;
48
40
}
0 commit comments