Interface FS

interface FS {
    contains?: ((root: string, file: string) => boolean);
    dirname?: ((file: string) => string);
    exists: ((filepath: string) => Promise<boolean>);
    existsSync: ((filepath: string) => boolean);
    fallback?: ((file: string) => undefined | string);
    readFile: ((filepath: string) => Promise<string>);
    readFileSync: ((filepath: string) => string);
    resolve: ((dir: string, file: string, ext: string) => string);
    sep?: string;
}

Properties

contains?: ((root: string, file: string) => boolean)

check if file is contained in root, always return true by default. Warning: not setting this could expose path traversal vulnerabilities.

dirname?: ((file: string) => string)

required for relative path resolving

exists: ((filepath: string) => Promise<boolean>)

check if a file exists asynchronously

existsSync: ((filepath: string) => boolean)

check if a file exists synchronously

fallback?: ((file: string) => undefined | string)

fallback file for lookup failure

readFile: ((filepath: string) => Promise<string>)

read a file asynchronously

readFileSync: ((filepath: string) => string)

read a file synchronously

resolve: ((dir: string, file: string, ext: string) => string)

resolve a file against directory, for given ext option

sep?: string

defaults to "/"