@@ -10,7 +10,20 @@ vi.mock("../../../utils/fs", () => ({
1010 fileExistsAtPath : vi . fn ( ) ,
1111} ) )
1212
13+ vi . mock ( "fs" , ( ) => ( {
14+ existsSync : vi . fn ( ) ,
15+ } ) )
16+
17+ vi . mock ( "module" , ( ) => ( {
18+ createRequire : vi . fn ( ) ,
19+ } ) )
20+
21+ import * as fs from "fs"
22+ import { createRequire } from "module"
23+
1324const mockFileExists = vi . mocked ( fileExistsAtPath )
25+ const mockExistsSync = vi . mocked ( fs . existsSync )
26+ const mockCreateRequire = vi . mocked ( createRequire )
1427
1528describe ( "Ripgrep line truncation" , ( ) => {
1629 // The default MAX_LINE_LENGTH is 500 in the implementation
@@ -67,6 +80,9 @@ describe("getBinPath", () => {
6780 beforeEach ( ( ) => {
6881 mockFileExists . mockReset ( )
6982 mockFileExists . mockResolvedValue ( false )
83+ mockExistsSync . mockReset ( )
84+ mockExistsSync . mockReturnValue ( false )
85+ mockCreateRequire . mockReset ( )
7086 } )
7187
7288 it ( "resolves ripgrep from the classic @vscode/ripgrep layout" , async ( ) => {
@@ -95,4 +111,29 @@ describe("getBinPath", () => {
95111
96112 expect ( await getBinPath ( appRoot ) ) . toBeUndefined ( )
97113 } )
114+
115+ // Regression test for https://github.com/Zoo-Code-Org/Zoo-Code/issues/1024
116+ // VS Code 1.130+ ships @vscode/ripgrep >=1.18, where the binary lives in a
117+ // platform-specific optional package resolved via the wrapper's package.json.
118+ // None of the six hardcoded candidate paths match this layout, so getBinPath
119+ // returns undefined on affected Windows installs, causing every task to hang.
120+ it ( "resolves ripgrep via the @vscode/ripgrep >=1.18 platform-package layout" , async ( ) => {
121+ const platformBin = `/vscode/ripgrep-${ process . platform } -${ process . arch } /bin/${ binName } `
122+
123+ // All static candidates miss.
124+ mockFileExists . mockResolvedValue ( false )
125+
126+ // Simulate @vscode /ripgrep wrapper manifest existing and resolving to the platform bin.
127+ mockExistsSync . mockReturnValue ( true )
128+ const mockRequireFromWrapper = { resolve : vi . fn ( ) . mockReturnValue ( platformBin ) }
129+ const mockRequireFromApp = { resolve : vi . fn ( ) . mockReturnValue ( "/vscode/ripgrep/index.js" ) }
130+ mockCreateRequire
131+ . mockReturnValueOnce ( mockRequireFromApp as unknown as NodeRequire )
132+ . mockReturnValueOnce ( mockRequireFromWrapper as unknown as NodeRequire )
133+
134+ // The resolved platform bin exists on disk.
135+ mockFileExists . mockImplementation ( async ( p : string ) => p === platformBin )
136+
137+ expect ( await getBinPath ( appRoot ) ) . toBe ( platformBin )
138+ } )
98139} )
0 commit comments