55 * Use of this source code is governed by an MIT-style license that can be
66 * found in the LICENSE file at https://angular.io/license
77 */
8+ import { JsonParseMode , isJsonObject , parseJson } from '@angular-devkit/core' ;
89import * as child_process from 'child_process' ;
910import * as fs from 'fs' ;
1011import * as path from 'path' ;
@@ -21,7 +22,7 @@ export class VersionCommand extends Command<VersionCommandSchema> {
2122 let projPkg ;
2223 try {
2324 projPkg = require ( path . resolve ( this . workspace . root , 'package.json' ) ) ;
24- } catch ( exception ) {
25+ } catch {
2526 projPkg = undefined ;
2627 }
2728
@@ -137,6 +138,7 @@ export class VersionCommand extends Command<VersionCommandSchema> {
137138 Angular CLI: ${ ngCliVersion }
138139 Node: ${ process . versions . node }
139140 OS: ${ process . platform } ${ process . arch }
141+
140142 Angular: ${ angularCoreVersion }
141143 ... ${ angularSameAsCore
142144 . reduce < string [ ] > ( ( acc , name ) => {
@@ -154,6 +156,7 @@ export class VersionCommand extends Command<VersionCommandSchema> {
154156 return acc ;
155157 } , [ ] )
156158 . join ( '\n... ' ) }
159+ Ivy Workspace: ${ projPkg ? this . getIvyWorkspace ( ) : '' }
157160
158161 Package${ namePad . slice ( 7 ) } Version
159162 -------${ namePad . replace ( / / g, '-' ) } ------------------
@@ -176,7 +179,7 @@ export class VersionCommand extends Command<VersionCommandSchema> {
176179
177180 return modulePkg . version ;
178181 }
179- } catch ( _ ) { }
182+ } catch { }
180183
181184 try {
182185 if ( cliNodeModules ) {
@@ -188,4 +191,22 @@ export class VersionCommand extends Command<VersionCommandSchema> {
188191
189192 return '<error>' ;
190193 }
194+
195+ private getIvyWorkspace ( ) : string {
196+ try {
197+ const content = fs . readFileSync ( path . resolve ( this . workspace . root , 'tsconfig.json' ) , 'utf-8' ) ;
198+ const tsConfig = parseJson ( content , JsonParseMode . Loose ) ;
199+ if ( ! isJsonObject ( tsConfig ) ) {
200+ return '<error>' ;
201+ }
202+
203+ const { angularCompilerOptions } = tsConfig ;
204+
205+ return isJsonObject ( angularCompilerOptions ) && angularCompilerOptions . enableIvy === false
206+ ? 'No'
207+ : 'Yes' ;
208+ } catch {
209+ return '<error>' ;
210+ }
211+ }
191212}
0 commit comments