@@ -12,9 +12,8 @@ import {
1212 WorkspaceNodeModulesArchitectHost ,
1313} from '@angular-devkit/architect/node' ;
1414import { json } from '@angular-devkit/core' ;
15- import { spawnSync } from 'child_process' ;
16- import { existsSync } from 'fs' ;
17- import { resolve } from 'path' ;
15+ import { existsSync } from 'node:fs' ;
16+ import { resolve } from 'node:path' ;
1817import { isPackageNameSafeForAnalytics } from '../analytics/analytics' ;
1918import { EventCustomDimension , EventCustomMetric } from '../analytics/analytics-parameters' ;
2019import { assertIsError } from '../utilities/error' ;
@@ -248,14 +247,14 @@ export abstract class ArchitectBaseCommandModule<T extends object>
248247 const packageToInstall = await this . getMissingTargetPackageToInstall ( choices ) ;
249248 if ( packageToInstall ) {
250249 // Example run: `ng add @angular-eslint/schematics`.
251- const binPath = resolve ( __dirname , '../../bin/ng.js' ) ;
252- const { error } = spawnSync ( process . execPath , [ binPath , 'add' , packageToInstall ] , {
253- stdio : 'inherit' ,
250+ const AddCommandModule = ( await import ( '../commands/add/cli' ) ) . default ;
251+ await new AddCommandModule ( this . context ) . run ( {
252+ interactive : true ,
253+ force : false ,
254+ dryRun : false ,
255+ defaults : false ,
256+ collection : packageToInstall ,
254257 } ) ;
255-
256- if ( error ) {
257- throw error ;
258- }
259258 }
260259 } else {
261260 // Non TTY display error message.
0 commit comments