11import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest' ;
22import * as cp from 'child_process' ;
3- import * as fs from 'fs' ;
3+ import * as fs from 'node: fs' ;
44import * as os from 'os' ;
55import * as path from 'path' ;
66import { CodeGraph } from '../src' ;
@@ -11,9 +11,9 @@ vi.mock('child_process', async importOriginal => {
1111 const actual = await importOriginal < typeof import ( 'child_process' ) > ( ) ;
1212 return { ...actual , execFileSync : vi . fn ( actual . execFileSync ) } ;
1313} ) ;
14- vi . mock ( 'fs' , async importOriginal => {
15- const actual = await importOriginal < typeof import ( 'fs' ) > ( ) ;
16- return { ...actual , readFileSync : vi . fn ( actual . readFileSync ) } ;
14+ vi . mock ( 'node: fs' , async importOriginal => {
15+ const actual = await importOriginal < typeof import ( 'node: fs' ) > ( ) ;
16+ return { ...actual , readFileSync : vi . fn ( actual . readFileSync ) , openSync : vi . fn ( actual . openSync ) } ;
1717} ) ;
1818
1919describe ( 'git index currency across commits and restores (#1829)' , ( ) => {
@@ -132,12 +132,12 @@ describe('git index currency across commits and restores (#1829)', () => {
132132
133133 it ( 'keeps a committed path pending when sync cannot read it' , async ( ) => {
134134 write ( 'new.ts' , 'newSymbol' ) ; commit ( ) ;
135- const real = fs . readFileSync ;
135+ const real = fs . openSync ;
136136 let injected = 0 ;
137- vi . spyOn ( fs , 'readFileSync ' ) . mockImplementation ( ( ( file : any , ...args : any [ ] ) => {
137+ vi . spyOn ( fs , 'openSync ' ) . mockImplementation ( ( ( file : any , ...args : any [ ] ) => {
138138 if ( String ( file ) === path . join ( root , 'new.ts' ) ) { injected ++ ; throw new Error ( 'Injected transient read error' ) ; }
139139 return ( real as any ) ( file , ...args ) ;
140- } ) as typeof fs . readFileSync ) ;
140+ } ) as typeof fs . openSync ) ;
141141 await cg . sync ( ) ;
142142 expect ( injected ) . toBeGreaterThan ( 0 ) ;
143143 expect ( symbols ( 'newSymbol' ) ) . not . toContain ( 'newSymbol' ) ;
0 commit comments