@@ -8,7 +8,7 @@ describe("ProviderInstallManager", () => {
88 const manager = new ProviderInstallManager ( [ codexDefinition ] , {
99 platform : "win32" ,
1010 commandExists,
11- execFile : vi . fn ( async ( ) => ( { stdout : "" , stderr : "" } ) ) ,
11+ runCommand : vi . fn ( async ( ) => ( { stdout : "" , stderr : "" } ) ) ,
1212 } ) ;
1313
1414 const job = await manager . start ( "codex" ) ;
@@ -26,7 +26,7 @@ describe("ProviderInstallManager", () => {
2626 const manager = new ProviderInstallManager ( [ codexDefinition ] , {
2727 platform : "linux" ,
2828 commandExists,
29- execFile : vi . fn ( async ( ) => ( { stdout : "" , stderr : "" } ) ) ,
29+ runCommand : vi . fn ( async ( ) => ( { stdout : "" , stderr : "" } ) ) ,
3030 } ) ;
3131
3232 const job = await manager . start ( "codex" ) ;
@@ -45,7 +45,7 @@ describe("ProviderInstallManager", () => {
4545 const manager = new ProviderInstallManager ( [ codexDefinition ] , {
4646 platform : "aix" ,
4747 commandExists : vi . fn ( async ( command : string ) => command === "npm" ) ,
48- execFile : vi . fn ( async ( ) => ( { stdout : "" , stderr : "" } ) ) ,
48+ runCommand : vi . fn ( async ( ) => ( { stdout : "" , stderr : "" } ) ) ,
4949 } ) ;
5050
5151 const job = await manager . start ( "codex" ) ;
@@ -71,7 +71,7 @@ describe("ProviderInstallManager", () => {
7171 const manager = new ProviderInstallManager ( [ codexDefinition ] , {
7272 platform : "darwin" ,
7373 commandExists : vi . fn ( async ( command : string ) => command === "npm" ) ,
74- execFile,
74+ runCommand : execFile ,
7575 } ) ;
7676
7777 const first = await manager . start ( "codex" ) ;
@@ -96,7 +96,7 @@ describe("ProviderInstallManager", () => {
9696 const manager = new ProviderInstallManager ( [ codexDefinition ] , {
9797 platform : "linux" ,
9898 commandExists,
99- execFile : vi . fn ( async ( ) => ( { stdout : "" , stderr : "" } ) ) ,
99+ runCommand : vi . fn ( async ( ) => ( { stdout : "" , stderr : "" } ) ) ,
100100 } ) ;
101101
102102 const firstPromise = manager . start ( "codex" ) ;
@@ -119,7 +119,7 @@ describe("ProviderInstallManager", () => {
119119 const manager = new ProviderInstallManager ( [ codexDefinition ] , {
120120 platform : "linux" ,
121121 commandExists : vi . fn ( async ( command : string ) => command === "npm" ) ,
122- execFile : vi . fn ( async ( ) => {
122+ runCommand : vi . fn ( async ( ) => {
123123 throw installError ;
124124 } ) ,
125125 } ) ;
@@ -147,49 +147,33 @@ describe("ProviderInstallManager", () => {
147147 expect ( stored ?. steps [ 0 ] ?. status ) . toBe ( "failed" ) ;
148148 } ) ;
149149
150- it ( "re-resolves and executes the installed npm executable on Windows install steps " , async ( ) => {
150+ it ( "executes Windows install steps with the declared command names " , async ( ) => {
151151 let npmInstalled = false ;
152152 let codexInstalled = false ;
153+ const commandExists = vi . fn ( async ( command : string ) => {
154+ if ( command === "winget" ) {
155+ return true ;
156+ }
157+ if ( command === "npm" ) {
158+ return npmInstalled ;
159+ }
160+ if ( command === "codex" ) {
161+ return codexInstalled ;
162+ }
163+ return false ;
164+ } ) ;
153165 const execFile = vi . fn (
154166 async ( file : string , args : string [ ] , _options ?: { windowsHide : boolean } ) => {
155- if ( file === "where" && args [ 0 ] === "winget" ) {
156- return {
157- stdout : "C:\\Users\\test\\AppData\\Local\\Microsoft\\WindowsApps\\winget.exe\r\n" ,
158- stderr : "" ,
159- } ;
160- }
161-
162- if ( file === "where" && args [ 0 ] === "npm" ) {
163- if ( ! npmInstalled ) {
164- throw new Error ( "npm unavailable" ) ;
165- }
166-
167- return {
168- stdout : "C:\\npm\\npm.cmd\r\n" ,
169- stderr : "" ,
170- } ;
171- }
172-
173- if ( file === "where" && args [ 0 ] === "codex" ) {
174- if ( ! codexInstalled ) {
175- throw new Error ( "codex unavailable" ) ;
176- }
177-
178- return {
179- stdout : "C:\\codex\\codex.exe\r\n" ,
180- stderr : "" ,
181- } ;
182- }
183-
184167 if (
185- file === "C:\\Users\\test\\AppData\\Local\\Microsoft\\WindowsApps\\ winget.exe " &&
168+ file === "winget" &&
186169 args . join ( " " ) === "install --id OpenJS.NodeJS.LTS --exact --silent"
187170 ) {
188171 npmInstalled = true ;
189172 return { stdout : "installed node" , stderr : "" } ;
190173 }
191174
192- if ( file === "C:\\npm\\npm.cmd" && args . join ( " " ) === "install -g @openai/codex" ) {
175+ if ( file === "npm" && args . join ( " " ) === "install -g @openai/codex" ) {
176+ expect ( npmInstalled ) . toBe ( true ) ;
193177 codexInstalled = true ;
194178 return { stdout : "installed codex" , stderr : "" } ;
195179 }
@@ -199,7 +183,8 @@ describe("ProviderInstallManager", () => {
199183 ) ;
200184 const manager = new ProviderInstallManager ( [ codexDefinition ] , {
201185 platform : "win32" ,
202- execFile,
186+ commandExists,
187+ runCommand : execFile ,
203188 } ) ;
204189
205190 const job = await manager . start ( "codex" ) ;
@@ -208,10 +193,8 @@ describe("ProviderInstallManager", () => {
208193 expect ( manager . get ( job . jobId ) ?. status ) . toBe ( "succeeded" ) ;
209194 } ) ;
210195
211- expect ( execFile ) . toHaveBeenCalledWith (
212- "C:\\npm\\npm.cmd" ,
213- [ "install" , "-g" , "@openai/codex" ] ,
214- { windowsHide : true }
215- ) ;
196+ expect ( execFile ) . toHaveBeenCalledWith ( "npm" , [ "install" , "-g" , "@openai/codex" ] , {
197+ windowsHide : true ,
198+ } ) ;
216199 } ) ;
217200} ) ;
0 commit comments