@@ -76,13 +76,11 @@ export interface Host {
7676 /**
7777 * Spawns a child process and returns a promise that resolves with the process's
7878 * output or rejects with a structured error.
79- * @param command The command to run.
8079 * @param args The arguments to pass to the command.
8180 * @param options Options for the child process.
8281 * @returns A promise that resolves with the standard output and standard error of the command.
8382 */
84- runCommand (
85- command : string ,
83+ executeNgCommand (
8684 args : readonly string [ ] ,
8785 options ?: {
8886 timeout ?: number ;
@@ -94,13 +92,11 @@ export interface Host {
9492
9593 /**
9694 * Spawns a long-running child process and returns the `ChildProcess` object.
97- * @param command The command to run.
9895 * @param args The arguments to pass to the command.
9996 * @param options Options for the child process.
10097 * @returns The spawned `ChildProcess` instance.
10198 */
102- spawn (
103- command : string ,
99+ startNgProcess (
104100 args : readonly string [ ] ,
105101 options ?: {
106102 stdio ?: 'pipe' | 'ignore' ;
@@ -125,13 +121,13 @@ export interface Host {
125121 setRoots ( roots : string [ ] ) : void ;
126122}
127123
128- function resolveCommand (
129- command : string ,
124+ function resolveNgCommand (
130125 args : readonly string [ ] ,
131126 cwd ?: string ,
132127) : { command : string ; args : readonly string [ ] } {
133- if ( command !== 'ng' || ! cwd ) {
134- return { command, args } ;
128+ const defaultCommand = { command : 'ng' , args } ;
129+ if ( ! cwd ) {
130+ return defaultCommand ;
135131 }
136132
137133 try {
@@ -152,7 +148,7 @@ function resolveCommand(
152148 // Failed to resolve the CLI binary, fall back to assuming `ng` is on PATH.
153149 }
154150
155- return { command , args } ;
151+ return defaultCommand ;
156152}
157153
158154/**
@@ -172,8 +168,7 @@ export const LocalWorkspaceHost: Host = {
172168 return nodeGlob ( pattern , { ...options , withFileTypes : true } ) ;
173169 } ,
174170
175- runCommand : async (
176- command : string ,
171+ executeNgCommand : async (
177172 args : readonly string [ ] ,
178173 options : {
179174 timeout ?: number ;
@@ -182,7 +177,7 @@ export const LocalWorkspaceHost: Host = {
182177 env ?: Record < string , string > ;
183178 } = { } ,
184179 ) : Promise < { logs : string [ ] } > => {
185- const resolved = resolveCommand ( command , args , options . cwd ) ;
180+ const resolved = resolveNgCommand ( args , options . cwd ) ;
186181 const signal = options . timeout ? AbortSignal . timeout ( options . timeout ) : undefined ;
187182
188183 return new Promise ( ( resolve , reject ) => {
@@ -223,16 +218,15 @@ export const LocalWorkspaceHost: Host = {
223218 } ) ;
224219 } ,
225220
226- spawn (
227- command : string ,
221+ startNgProcess (
228222 args : readonly string [ ] ,
229223 options : {
230224 stdio ?: 'pipe' | 'ignore' ;
231225 cwd ?: string ;
232226 env ?: Record < string , string > ;
233227 } = { } ,
234228 ) : ChildProcess {
235- const resolved = resolveCommand ( command , args , options . cwd ) ;
229+ const resolved = resolveNgCommand ( args , options . cwd ) ;
236230
237231 return spawn ( resolved . command , resolved . args , {
238232 shell : false ,
@@ -372,23 +366,20 @@ export function createRootRestrictedHost(
372366
373367 return baseHost . glob ( pattern , options ) ;
374368 } ,
375- runCommand ( command : string , args : readonly string [ ] , options : { cwd ?: string } = { } ) {
376- const effectiveCwd = options . cwd ?? process . cwd ( ) ;
369+ executeNgCommand (
370+ args : readonly string [ ] ,
371+ options : Parameters < Host [ 'executeNgCommand' ] > [ 1 ] = { } ,
372+ ) {
373+ const effectiveCwd = options ?. cwd ?? process . cwd ( ) ;
377374 checkPath ( effectiveCwd ) ;
378- if ( command . includes ( '/' ) || command . includes ( '\\' ) ) {
379- checkPath ( resolve ( effectiveCwd , command ) ) ;
380- }
381375
382- return baseHost . runCommand ( command , args , options ) ;
376+ return baseHost . executeNgCommand ( args , options ) ;
383377 } ,
384- spawn ( command : string , args : readonly string [ ] , options : { cwd ?: string } = { } ) {
385- const effectiveCwd = options . cwd ?? process . cwd ( ) ;
378+ startNgProcess ( args : readonly string [ ] , options : Parameters < Host [ 'startNgProcess' ] > [ 1 ] = { } ) {
379+ const effectiveCwd = options ? .cwd ?? process . cwd ( ) ;
386380 checkPath ( effectiveCwd ) ;
387- if ( command . includes ( '/' ) || command . includes ( '\\' ) ) {
388- checkPath ( resolve ( effectiveCwd , command ) ) ;
389- }
390381
391- return baseHost . spawn ( command , args , options ) ;
382+ return baseHost . startNgProcess ( args , options ) ;
392383 } ,
393384 } ;
394385}
0 commit comments