fs-extender
Version:
Extras suite for node fs module
40 lines (39 loc) • 1.51 kB
TypeScript
/// <reference types="node" />
import * as util from "../util";
import * as fs from "../../patch";
/**
* EnsureDir - ensures directory existence on file system
*
* ```js
* import * as fs from "fs-extender"
* fs.ensureDir(path,(err)=>{
* if(!err) {
* console.log(`${path} is ensured in the file system.`);
* }
* });
* ```
*
* @param path - the path to the directory
* @param options - used to create the directory or modify it, options can be
* - `mode` - to set the directory mode, default: 0o777
* @param callback - `(err: Error | null, path: fs.PathLike)
*/
export declare function ensureDir(path: fs.PathLike, options: util.EnsureOptionsDir, callback: (err: NodeJS.ErrnoException, path: fs.PathLike) => void): void;
export declare function ensureDir(path: fs.PathLike, callback: (err: NodeJS.ErrnoException, path: fs.PathLike) => void): void;
export declare namespace promises {
/**
* EnsureDir - ensures directory existence on file system
*
* ```js
* import * as fs from "fs-extender"
* await fs.promises.ensureDir(path);
* console.log(`${path} is ensured in the file system.`);
* ```
*
* @param path - the path to the directory
* @param options - used to create the directory or modify it, options can be
* - `mode` - to set the directory mode, default: 0o777
* @return Promise<string> path to the directory
*/
function ensureDir(path: fs.PathLike, options?: util.EnsureOptionsDir): Promise<fs.PathLike>;
}