UNPKG

2.04 kBTypeScriptView Raw
1// Type definitions for fs-promise 1.0
2// Project: https://github.com/kevinbeaty/fs-promise#readme
3// Definitions by: Thiago de Arruda <https://github.com/tarruda>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6/// <reference types="node" />
7
8export * from "mz/fs";
9export * from "fs-extra";
10
11export interface WriteOptions {
12 encoding?: string;
13 mode?: number;
14 flag?: string;
15}
16
17type JsonReplacerArray = Array<number | string>;
18
19type JsonReplacerFunction = (key: string, value: any) => any;
20
21type JsonReplacer = JsonReplacerArray | JsonReplacerFunction;
22
23export interface WriteJsonOptions extends WriteOptions {
24 spaces?: number;
25 replacer?: JsonReplacer;
26}
27
28export interface ReadJsonOptions {
29 encoding: string;
30 flag?: string;
31 reviver: (key: any, value: any) => any;
32}
33
34export function copy(src: string, dst: string): Promise<void>;
35export function emptyDir(dir: string): Promise<void>;
36export function ensureFile(file: string): Promise<void>;
37export function ensureDir(dir: string): Promise<void>;
38export function ensureLink(srcpath: string, dstpath: string): Promise<void>;
39export function ensureSymlink(srcpath: string, dstpath: string, type?: "dir" | "file" | "junction"): Promise<void>;
40export function mkdirs(dir: string): Promise<void>;
41export function move(src: string, dst: string): Promise<void>;
42export function outputFile(file: string, data: string | Buffer, options?: WriteOptions): Promise<void>;
43export function outputJson(file: string, data: any, options?: WriteJsonOptions): Promise<void>;
44export function readJson(file: string, options?: ReadJsonOptions): Promise<any>;
45export function remove(path: string): Promise<void>;
46export function writeJson(file: string, data: any, options?: WriteJsonOptions): Promise<void>;
47
48// aliases
49export {
50 emptyDir as emptydir,
51 ensureFile as createFile,
52 ensureLink as createLink,
53 ensureSymlink as createSymlink,
54 mkdirs as mkdirp,
55 outputJson as outputJSON,
56 readJson as readJSON,
57 writeJson as writeJSON
58};