UNPKG

@salesforce/core

Version:

Core libraries to interact with SFDX projects, orgs, and APIs.

39 lines (38 loc) • 1.73 kB
import type * as nodeFs from 'node:fs'; import type { IFs as MemFs } from 'memfs'; type NodeFs = typeof nodeFs; type CommonKeys<T, U> = keyof T & keyof U; type IntersectionType<T, U> = { [K in CommonKeys<T, U>]: T[K] extends (...args: any[]) => any ? T[K] extends U[K] ? T[K] : U[K] extends T[K] ? U[K] : any : T[K] extends U[K] ? T[K] : U[K] extends T[K] ? U[K] : T[K]; }; type BaseVirtualFs = IntersectionType<NodeFs, MemFs>; export type VirtualFs = Omit<BaseVirtualFs, 'writeFileSync' | 'readFileSync' | 'statSync' | 'promises' | 'mkdtempSync' | 'createWriteStream' | 'mkdirSync'> & { promises: Omit<BaseVirtualFs['promises'], 'writeFile' | 'readFile'> & { writeFile: (file: string, data: string | Buffer, options?: BufferEncoding | { encoding?: BufferEncoding; mode?: string | number; }) => Promise<void>; readFile: { (path: string): Promise<Buffer>; (path: string, options: BufferEncoding | { encoding: BufferEncoding; }): Promise<string>; }; }; readFileSync: { (path: string, options: BufferEncoding | { encoding: BufferEncoding; }): string; (path: string): Buffer; }; writeFileSync: (file: string, data: string | Buffer, options?: BufferEncoding | { encoding?: BufferEncoding; mode?: string | number; }) => void; /** there are some differences between node:fs and memfs for statSync around bigint stats. Be careful if using those */ statSync: typeof nodeFs.statSync; mkdtempSync: typeof nodeFs.mkdtempSync; createWriteStream: typeof nodeFs.createWriteStream; mkdirSync: typeof nodeFs.mkdirSync; }; export {};