import { PathLike } from 'fs'; import type { PathOrFileDescriptor } from 'fs'; import { promises } from 'fs'; import { readFileSync } from 'fs'; import { RmDirOptions } from 'fs'; import type { WriteFileOptions } from 'fs'; import { writeFileSync } from 'fs'; /** * copy file * * @param paths - path or file, support array * @param target - target path * @param options - CpOptions */ export declare function cp(paths: PathLike | PathLike[], target: PathLike, options?: CpOptions): Promise; export declare interface CpOptions extends RmDirOptions { /** * force delete, default: true */ force?: boolean; /** * do not output logs, default: true */ silent?: boolean; } /** * copy file sync * * @param paths - path or file, support array * @param target - target path * @param options - CpOptions */ export declare function cpSync(paths: PathLike | PathLike[], target: PathLike, options?: CpOptions): void; /** * resolve realpath * * @param path - the path * @returns result - the realpath */ export declare function getRealPath(path: string): Promise; /** * resolve realpath sync function * * @param path - the path * @returns result - the realpath */ export declare function getRealPathSync(path: string): string; /** * move file * * @param paths - path or file, support array * @param target - target path * @param options - MvOptions */ export declare function mv(paths: PathLike | PathLike[], target: PathLike, options?: MvOptions): Promise; export declare interface MvOptions extends CpOptions, RmOptions { /** * force delete, default: true */ force?: boolean; /** * do not output logs, default: true */ silent?: boolean; } /** * move file sync * * @param paths - path or file, support array * @param target - target path * @param options - MvOptions */ export declare function mvSync(paths: PathLike | PathLike[], target: PathLike, options?: MvOptions): void; /** * read json file * * @example * ```ts * import { readJSON } from '@node-kit/extra.fs' * const data = await readJSON('/path/of/json', { encoding: 'utf8 }) // \{ "name": "saqqdy" \} * ``` * @param args - Parameters\ * @returns result - json | \{\} */ export declare function readJSON(...args: Parameters): Promise | null>; /** * read json file sync function * * @example * ```ts * import { readJSONSync } from '@node-kit/extra.fs' * const data = readJSONSync('/path/of/json', { encoding: 'utf8 }) // \{ "name": "saqqdy" \} * ``` * @param args - Parameters\ * @returns result - json | \{\} */ export declare function readJSONSync(...args: Parameters): Record | null; /** * remove file * * @param paths - path or file, support array * @param options - RmOptions */ export declare function rm(paths: PathLike | PathLike[], options?: RmOptions): Promise; export declare interface RmOptions extends RmDirOptions { /** * force delete, default: true */ force?: boolean; /** * do not output logs, default: true */ silent?: boolean; } /** * remove file sync * * @param paths - path or file, support array * @param options - RmOptions */ export declare function rmSync(paths: PathLike | PathLike[], options?: RmOptions): void; /** * write json file * * @example * ```ts * import { writeJSON } from '@node-kit/extra.fs' * writeJSON('/path/of/file', 'test data', { encoding: 'utf8 }).then(() => {}) * ``` * @param args - Parameters\ */ export declare function writeJSON(file: Parameters[0], data: Record | Parameters[1], options?: WriteFileOptions): Promise; /** * write json file sync function * * @example * ```ts * import { writeJSONSync } from '@node-kit/extra.fs' * writeJSONSync('/path/of/file', 'test data', { encoding: 'utf8 }) * ``` * @param args - Parameters\ */ export declare function writeJSONSync(file: PathOrFileDescriptor, data: Record | Parameters[1], options?: WriteFileOptions): void; export { }