@@ -12,9 +12,8 @@ import {
12
12
WorkspaceNodeModulesArchitectHost ,
13
13
} from '@angular-devkit/architect/node' ;
14
14
import { 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' ;
18
17
import { isPackageNameSafeForAnalytics } from '../analytics/analytics' ;
19
18
import { EventCustomDimension , EventCustomMetric } from '../analytics/analytics-parameters' ;
20
19
import { assertIsError } from '../utilities/error' ;
@@ -248,14 +247,14 @@ export abstract class ArchitectBaseCommandModule<T extends object>
248
247
const packageToInstall = await this . getMissingTargetPackageToInstall ( choices ) ;
249
248
if ( packageToInstall ) {
250
249
// 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 ,
254
257
} ) ;
255
-
256
- if ( error ) {
257
- throw error ;
258
- }
259
258
}
260
259
} else {
261
260
// Non TTY display error message.
0 commit comments