@a2r/fs
Version:
A2R file system library
69 lines (68 loc) • 2.87 kB
TypeScript
/// <reference types="node" />
import * as fs from 'fs';
/**
* Create a directory
*/
export declare const mkDir: typeof fs.mkdir.__promisify__;
/**
* Delete a directory.
*/
export declare const rmDir: typeof fs.rmdir.__promisify__;
/**
* The [UNIX command](http://en.wikipedia.org/wiki/Rm_(Unix)) `rm -rf` for node
*/
export declare const rimraf: (arg1: string) => Promise<void>;
/**
* Writes data to a file, replacing the file if it already exists.
*/
export declare const writeFile: typeof fs.writeFile.__promisify__;
/**
* Read a directory.
*/
export declare const readDir: typeof fs.readdir.__promisify__;
/**
* Reads the entire contents of a file.
*/
export declare const readFile: typeof fs.readFile.__promisify__;
/**
* Copies `src` to `dest`. By default, dest is overwritten if it already exists. No arguments other than a possible exception are given to the callback function. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination.
*/
export declare const copyFile: typeof fs.copyFile.__promisify__;
/**
* Deletes a name and possibly the file it refers to.
*/
export declare const unlink: typeof fs.unlink.__promisify__;
/**
* Change the name or location of a file or directory
*/
export declare const rename: typeof fs.rename.__promisify__;
/**
* Test whether or not the given path exists by checking with the file system.
* @param {fs.PathLike} pathToCheck A path to a file or directory. If a URL is provided, it must use the `file:` protocol. URL support is experimental.
*/
export declare const exists: (pathToCheck: fs.PathLike) => Promise<boolean>;
/**
* Empties given folder by removing it and creating it again
* @param {string} folderPath Folder path to be emptied
*/
export declare const emptyFolder: (folderPath: string) => Promise<void>;
/**
* Ensures that given dir path exists
* @param {string} folderPath Path to ensure
* @param {fs.MakeDirectoryOptions} options Options
*/
export declare const ensureDir: (folderPath: string, options?: fs.MakeDirectoryOptions | undefined, recursive?: boolean) => Promise<void>;
/**
* Gets files recursively
* @param folderPath Path to get files from
* @param extName Extension names to filter files (including `.`)
*/
export declare const getFilesRecursively: (folderPath: string, extName?: string[] | undefined) => Promise<string[]>;
/**
* Copies contents recursively from `fromPath` to `destPath`
* @param {string} fromPath Source path
* @param {string} destPath Destination path
* @param {boolean} [hard=true] Hard mode (overwrites existing files)
* @param {string} [relativePath=''] Relative path
*/
export declare const copyContents: (fromPath: string, destPath: string, hard?: boolean, relativePath?: string) => Promise<void>;