@@ -13,23 +13,33 @@ import { getWorkspace } from '../../utility/workspace';
13
13
import { Builders } from '../../utility/workspace-models' ;
14
14
15
15
export default function ( ) : Rule {
16
- return async ( host ) => {
16
+ return async ( host , context ) => {
17
17
// Workspace level tsconfig
18
18
updateTarget ( host , 'tsconfig.json' ) ;
19
19
20
20
const workspace = await getWorkspace ( host ) ;
21
21
22
22
// Find all tsconfig which are refereces used by builders
23
23
for ( const [ , project ] of workspace . projects ) {
24
- for ( const [ , target ] of project . targets ) {
24
+ for ( const [ targetName , target ] of project . targets ) {
25
25
// Update all other known CLI builders that use a tsconfig
26
26
const tsConfigs = [ target . options || { } , ...Object . values ( target . configurations || { } ) ]
27
27
. filter ( ( opt ) => typeof opt ?. tsConfig === 'string' )
28
28
. map ( ( opt ) => ( opt as { tsConfig : string } ) . tsConfig ) ;
29
29
30
- const uniqueTsConfigs = [ ...new Set ( tsConfigs ) ] ;
30
+ const uniqueTsConfigs = new Set ( tsConfigs ) ;
31
+ for ( const tsConfig of uniqueTsConfigs ) {
32
+ if ( host . exists ( tsConfig ) ) {
33
+ continue ;
34
+ }
31
35
32
- if ( uniqueTsConfigs . length < 1 ) {
36
+ uniqueTsConfigs . delete ( tsConfig ) ;
37
+ context . logger . warn (
38
+ `'${ tsConfig } ' referenced in the '${ targetName } ' target does not exist.` ,
39
+ ) ;
40
+ }
41
+
42
+ if ( ! uniqueTsConfigs . size ) {
33
43
continue ;
34
44
}
35
45
0 commit comments