UNPKG

enola

Version:

API and CLI for obliterating files and directories

60 lines (59 loc) 2.4 kB
import { ResourceType } from "./../fs/stat"; import { Errors } from "./../errors"; /** * `nuke` operation information. */ export declare type NukeResult = ({ /** * Information about the resource. */ stats: { /** The path that was requested to be nuked. */ path: string; /** The type of the resource. */ type: ResourceType; }; /** If the requested resource was a directory, this array will contain the * result of all nuke operations performed on the directory's items. */ children: NukeResult[]; /** A `boolean` whose value is `true` if the operation succeeded (i.e., * produced the desired result) and `false` otherwise. */ success: boolean; /** A warning that was produced by the operation, if one occured. */ warn?: Errors; }); /** * Asynchronously obliterate the file/directory at the specified path. * * If the file/directory does not exist, a warning will be returned. This is * because the operation is invalid, but the desired result of the operation has * been met. * * @param {string} path * The path of the file/directory to destroy. The path can either be * absolute, or relative to the current working directory. * @param {boolean | undefined} exists * Optional `boolean` parameter. If `false`, the function will return * immediately. This parameter is automatically provided internally * when this function is called recursively. * @return {Promise<NukeResult>} * A `Promise` which resolves to a `NukeResult` object containing * information about the operation once the operation has completed. */ export declare function nuke(dir: string): (Promise<NukeResult>); /** * Obliterate the file/directory at the specified path. * * If the file/directory does not exist, a warning will be returned. This is * because the operation is invalid, but the desired result of the operation has * been met. * * @param {string} dir * The path of the file/directory to destroy. The path can either be * absolute, or relative to the current working directory. * @return {NukeResult} * A `NukeResult` object containing information about the operation * once the operation has completed. * @throws {Error} */ export declare function nukeSync(dir: string): (NukeResult | never);