UNPKG

nxkit

Version:

This is a collection of tools, independent of any other libraries

94 lines (93 loc) 3.29 kB
/// <reference types="node" /> import * as fs from 'fs'; export * from 'fs'; declare type NoParamCallback = fs.NoParamCallback; declare type CancelParamCallback = (err: NodeJS.ErrnoException | null, r?: boolean) => void; /** * set dir and file */ export declare function chownr(path: string, uid: number, gid: number, cb: NoParamCallback): void; /** * set user file weight * @param {String} path * @param {String} mode * @param {Function} cb (Optional) */ export declare function chmodr(path: string, mode: number, cb: NoParamCallback): void; export declare var remove: typeof fs.unlink; export declare var removeSync: typeof fs.unlinkSync; /** * remove all file async * @param {String} path * @param {Function} cb (Optional) */ export declare function remover(path: string, cb: CancelParamCallback): { cancel: () => void; }; /** * 删除文件与文件夹 */ export declare function removerSync(path: string): void; export interface CopyOptions { ignore_hide?: boolean; replace?: boolean; symlink?: boolean; isCancel?: (source: string, target: string) => boolean; } /** * copy all file * @param {String} path * @param {String} target * @param {Object} options (Optional) * @param {Function} cb (Optional) */ export declare function copy(path: string, target: string, options?: CopyOptions | CancelParamCallback, cb?: CancelParamCallback): void | { cancel: () => void; }; /** * copy all file sync * @param {String} path * @param {String} target * @param {Object} options (Optional) */ export declare function copySync(path: string, target: string, options?: CopyOptions): void; export declare type MkdirOptopns = string | number | fs.MakeDirectoryOptions | null | undefined; /** * create all file dir * @param {String} path * @param {String} mode (Optional) * @param {Function} cb (Optional) */ export declare function mkdirp(path: string, mode?: MkdirOptopns | NoParamCallback, cb?: NoParamCallback): void; /** * create all file dir sync * @param {String} path * @param {String} mode (Optional) */ export declare function mkdirpSync(path: string, mode?: MkdirOptopns): void; export interface StatsDescribe extends fs.Stats { name: string; children: StatsDescribe[]; } export declare type EachDirectoryCallback = (stats: StatsDescribe, pathname: string) => (boolean | void); /** * get all info * @param {String} path * @param {Boolean} depth * @param {Function} cb */ export declare function list(path: string, depth?: boolean | EachDirectoryCallback, each_cb?: EachDirectoryCallback): Promise<StatsDescribe[]>; /** * get dir info */ export declare function listSync(path: string, depth?: boolean | EachDirectoryCallback, each_cb?: EachDirectoryCallback): StatsDescribe[]; export declare var ls: typeof list; export declare var ls_sync: typeof listSync; export declare var mkdir_p_sync: typeof mkdirpSync; export declare var mkdir_p: typeof mkdirp; export declare var cp_sync: typeof copySync; export declare var cp: typeof copy; export declare var rm_r_sync: typeof removerSync; export declare var rm_r: typeof remover; export declare var chmod_r: typeof chmodr; export declare var chown_r: typeof chownr;