@@ -247,10 +247,10 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
247247 fs . writeSync ( logFDs . get ( asarPath ) , `${ offset } : ${ filePath } \n` ) ;
248248 } ;
249249
250- const { lstatSync } = fs ;
251- fs . lstatSync = ( pathArgument : string , options : any ) => {
250+ const { lstatSync : nativeLstatSync } = fs ;
251+ fs . lstatSync = function lstatSync ( pathArgument : string , options : any ) {
252252 const pathInfo = splitPath ( pathArgument ) ;
253- if ( ! pathInfo . isAsar ) return lstatSync ( pathArgument , options ) ;
253+ if ( ! pathInfo . isAsar ) return nativeLstatSync ( pathArgument , options ) ;
254254 const { asarPath, filePath } = pathInfo ;
255255
256256 const archive = getOrCreateArchive ( asarPath ) ;
@@ -262,14 +262,14 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
262262 return asarStatsToFsStats ( stats ) ;
263263 } ;
264264
265- const { lstat } = fs ;
266- fs . lstat = function ( pathArgument : string , options : any , callback : any ) {
265+ const { lstat : nativeLstat } = fs ;
266+ fs . lstat = function lstat ( pathArgument : string , options : any , callback : any ) {
267267 const pathInfo = splitPath ( pathArgument ) ;
268268 if ( typeof options === 'function' ) {
269269 callback = options ;
270270 options = { } ;
271271 }
272- if ( ! pathInfo . isAsar ) return lstat ( pathArgument , options , callback ) ;
272+ if ( ! pathInfo . isAsar ) return nativeLstat ( pathArgument , options , callback ) ;
273273 const { asarPath, filePath } = pathInfo ;
274274
275275 const archive = getOrCreateArchive ( asarPath ) ;
@@ -292,23 +292,23 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
292292
293293 fs . promises . lstat = util . promisify ( fs . lstat ) ;
294294
295- const { statSync } = fs ;
296- fs . statSync = ( pathArgument : string , options : any ) => {
295+ const { statSync : nativeStatSync } = fs ;
296+ fs . statSync = function statSync ( pathArgument : string , options : any ) {
297297 const { isAsar } = splitPath ( pathArgument ) ;
298- if ( ! isAsar ) return statSync ( pathArgument , options ) ;
298+ if ( ! isAsar ) return nativeStatSync ( pathArgument , options ) ;
299299
300300 // Do not distinguish links for now.
301301 return fs . lstatSync ( pathArgument , options ) ;
302302 } ;
303303
304- const { stat } = fs ;
305- fs . stat = ( pathArgument : string , options : any , callback : any ) => {
304+ const { stat : nativeStat } = fs ;
305+ fs . stat = function stat ( pathArgument : string , options : any , callback : any ) {
306306 const { isAsar } = splitPath ( pathArgument ) ;
307307 if ( typeof options === 'function' ) {
308308 callback = options ;
309309 options = { } ;
310310 }
311- if ( ! isAsar ) return stat ( pathArgument , options , callback ) ;
311+ if ( ! isAsar ) return nativeStat ( pathArgument , options , callback ) ;
312312
313313 // Do not distinguish links for now.
314314 process . nextTick ( ( ) => fs . lstat ( pathArgument , options , callback ) ) ;
@@ -317,7 +317,7 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
317317 fs . promises . stat = util . promisify ( fs . stat ) ;
318318
319319 const wrapRealpathSync = function ( realpathSync : Function ) {
320- return function ( this : any , pathArgument : string , options : any ) {
320+ return function realPathSync ( this : any , pathArgument : string , options : any ) {
321321 const pathInfo = splitPath ( pathArgument ) ;
322322 if ( ! pathInfo . isAsar ) return realpathSync . apply ( this , arguments ) ;
323323 const { asarPath, filePath } = pathInfo ;
@@ -382,10 +382,10 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
382382
383383 fs . promises . realpath = util . promisify ( fs . realpath . native ) ;
384384
385- const { exists } = fs ;
386- fs . exists = ( pathArgument : string , callback : any ) => {
385+ const { exists : nativeExists } = fs ;
386+ fs . exists = function exists ( pathArgument : string , callback : any ) {
387387 const pathInfo = splitPath ( pathArgument ) ;
388- if ( ! pathInfo . isAsar ) return exists ( pathArgument , callback ) ;
388+ if ( ! pathInfo . isAsar ) return nativeExists ( pathArgument , callback ) ;
389389 const { asarPath, filePath } = pathInfo ;
390390
391391 const archive = getOrCreateArchive ( asarPath ) ;
@@ -399,9 +399,10 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
399399 nextTick ( callback , [ pathExists ] ) ;
400400 } ;
401401
402- fs . exists [ util . promisify . custom ] = ( pathArgument : string ) => {
402+ const { exists : existsPromise } = fs . promises ;
403+ fs . promises . exists = function exists ( pathArgument : string ) {
403404 const pathInfo = splitPath ( pathArgument ) ;
404- if ( ! pathInfo . isAsar ) return exists [ util . promisify . custom ] ( pathArgument ) ;
405+ if ( ! pathInfo . isAsar ) return existsPromise . apply ( this , pathArgument ) ;
405406 const { asarPath, filePath } = pathInfo ;
406407
407408 const archive = getOrCreateArchive ( asarPath ) ;
@@ -413,6 +414,8 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
413414 return Promise . resolve ( archive . stat ( filePath ) !== false ) ;
414415 } ;
415416
417+ console . log ( fs ) ;
418+
416419 const { existsSync } = fs ;
417420 fs . existsSync = ( pathArgument : string ) => {
418421 const pathInfo = splitPath ( pathArgument ) ;
@@ -425,10 +428,10 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
425428 return archive . stat ( filePath ) !== false ;
426429 } ;
427430
428- const { access } = fs ;
429- fs . access = function ( pathArgument : string , mode : any , callback : any ) {
431+ const { access : nativeAccess } = fs ;
432+ fs . access = function access ( pathArgument : string , mode : any , callback : any ) {
430433 const pathInfo = splitPath ( pathArgument ) ;
431- if ( ! pathInfo . isAsar ) return access . apply ( this , arguments ) ;
434+ if ( ! pathInfo . isAsar ) return nativeAccess . apply ( this , arguments ) ;
432435 const { asarPath, filePath } = pathInfo ;
433436
434437 if ( typeof mode === 'function' ) {
@@ -575,7 +578,7 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
575578
576579 const { readFile : readFilePromise } = fs . promises ;
577580 // eslint-disable-next-line @typescript-eslint/no-unused-vars
578- fs . promises . readFile = function ( pathArgument : string , options : any ) {
581+ fs . promises . readFile = function readFile ( pathArgument : string , options : any ) {
579582 const pathInfo = splitPath ( pathArgument ) ;
580583 if ( ! pathInfo . isAsar ) {
581584 return readFilePromise . apply ( this , arguments ) ;
0 commit comments