feat(fs-extra): update typings to 3.0.x (#16218)

* feat(fs-extra): update typyings to `3.0.x`

* feat(fs-extra): update typings to `3.0.x`

* test(fs-extra): add more test coverage

* add `pathExists`

* fix lint issues

* fix lint issues

* add `TypeScript Version: 2.2'

* add more tests

* change `interface` to `type`

* add typescript version

* add missing semicolon

* add universalify fs async methods

* add `fs` methods

* feat(fs-extra): update typings to `3.0.x`

* fix lint issues

* fix more lint issues

* fs-extra: add `mkdtemp`

* remove extra breakline

* remove `walk` and overall improvments

* fix tests

* add options to test

* remove `CopyFilterFunction` and `CopyFilter`

* remove `CopyFilterFunction` and `CopyFilter`

* fix test

* re add `CopyFilter`

* fs-extra: fix CopyFilter

* fs-extra: remove `MkdirOptions`

* fs-extra: remove exra interfaces

* feat(fs-extra): update typings to
This commit is contained in:
Alan Agius
2017-05-01 13:56:02 -07:00
committed by Mohamed Hegazy
parent 950c9cdca9
commit 3ff7e25c70
5 changed files with 391 additions and 148 deletions
+7 -1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/overlookmotel/fs-extra-promise
// Definitions by: midknight41 <https://github.com/midknight41>, Jason Swearingen <https://github.com/jasonswearingen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
/// <reference types="bluebird" />
@@ -10,10 +11,15 @@
import * as stream from 'stream';
import { Stats } from 'fs';
import * as Promise from 'bluebird';
import { CopyFilter, CopyOptions, ReadOptions, WriteOptions, MkdirOptions, MoveOptions } from 'fs-extra';
import { CopyFilter, CopyOptions, ReadOptions, WriteOptions, MoveOptions } from 'fs-extra';
export * from 'fs-extra';
export interface MkdirOptions {
fs?: any;
mode?: number;
}
//promisified versions
export declare function copyAsync(src: string, dest: string): Promise<void>;
export declare function copyAsync(src: string, dest: string, filter: CopyFilter): Promise<void>;
+133 -25
View File
@@ -1,106 +1,214 @@
import * as fs from 'fs-extra';
import * as Path from 'path';
const len = 2;
const src = "";
const dest = "";
const file = "";
const dir = "";
const path = "";
const data = "";
const uid = 0;
const gid = 0;
const fd = 0;
const modeNum = 0;
const modeStr = "";
const object = {};
const errorCallback = (err: Error) => {};
const errorCallback = (err: Error) => { };
const readOptions: fs.ReadOptions = {
reviver : {}
reviver: {}
};
const writeOptions: fs.WriteOptions = {
replacer: {}
replacer: {}
};
fs.moveSync(src, dest, {});
fs.move(src, dest, {}).then(() => {
// stub
});
fs.move(src, dest).then(() => {
// stub
});
fs.move(src, dest, {}, () => {
// stub
});
fs.move(src, dest, () => {
// stub
});
fs.copy(src, dest).then(() => {
// stub
});
fs.copy(src, dest, { overwrite: true }).then(() => {
// stub
});
fs.copy(src, dest, errorCallback);
fs.copy(src, dest, (src: string) => {
return false;
}, errorCallback);
fs.copy(src, dest, (src: string) => false, errorCallback);
fs.copy(src, dest,
{
clobber: true,
overwrite: true,
preserveTimestamps: true,
filter: (src: string) => { return false; }
filter: (src: string) => false
},
errorCallback
);
fs.copy(src, dest,
{
clobber: true,
overwrite: true,
preserveTimestamps: true,
filter: /.*/
},
errorCallback
);
fs.copySync(src, dest);
fs.copySync(src, dest, (src: string) => {
return false;
});
fs.copySync(src, dest, (src: string) => false);
fs.copySync(src, dest, /.*/);
fs.copySync(src, dest,
{
clobber: true,
overwrite: true,
preserveTimestamps: true,
filter: (src: string) => { return false; }
filter: (src: string) => false
}
);
fs.copySync(src, dest,
{
clobber: true,
overwrite: true,
preserveTimestamps: true,
filter: /.*/
}
);
fs.createFile(file).then(() => {
// stub
});
fs.createFile(file, errorCallback);
fs.createFileSync(file);
fs.mkdirs(dir).then(() => {
// stub
});
fs.mkdirp(dir).then(() => {
// stub
});
fs.mkdirs(dir, errorCallback);
fs.mkdirs(dir, {}, errorCallback);
fs.mkdirsSync(dir);
fs.mkdirsSync(dir, {});
fs.mkdirp(dir, errorCallback);
fs.mkdirp(dir, {}, errorCallback);
fs.mkdirpSync(dir);
fs.mkdirpSync(dir, {});
fs.outputFile(file, data).then(() => {
// stub
});
fs.outputFile(file, data, errorCallback);
fs.outputFileSync(file, data);
fs.outputJson(file, data, errorCallback);
fs.outputJson(file, data, {
spaces: 2
}).then(() => {
// stub
});
fs.outputJson(file, data, {
spaces: 2
}, errorCallback);
fs.outputJSON(file, data, errorCallback);
fs.outputJSON(file, data).then(() => {
// stub
});
fs.outputJsonSync(file, data);
fs.outputJSONSync(file, data);
fs.readJson(file, (error: Error, jsonObject: any) => {});
fs.readJson(file, readOptions, (error: Error, jsonObject: any) => {});
fs.readJSON(file, (error: Error, jsonObject: any) => {});
fs.readJSON(file, readOptions, (error: Error, jsonObject: any) => {});
fs.readJson(file).then(() => {
// stub
});
fs.readJson(file, readOptions).then(() => {
// stub
});
fs.readJson(file, (error: Error, jsonObject: any) => { });
fs.readJson(file, readOptions, (error: Error, jsonObject: any) => { });
fs.readJSON(file, (error: Error, jsonObject: any) => { });
fs.readJSON(file, readOptions, (error: Error, jsonObject: any) => { });
fs.readJsonSync(file, readOptions);
fs.readJSONSync(file, readOptions);
fs.remove(dir, errorCallback);
fs.remove(dir).then(() => {
// stub
});
fs.removeSync(dir);
fs.writeJson(file, object).then(() => {
// stub
});
fs.writeJSON(file, object).then(() => {
// stub
});
fs.writeJson(file, object, errorCallback);
fs.writeJson(file, object, writeOptions, errorCallback);
fs.writeJSON(file, object, errorCallback);
fs.writeJSON(file, object, writeOptions, errorCallback);
fs.writeJson(file, object, writeOptions).then(() => {
// stub
});
fs.writeJSON(file, object, writeOptions).then(() => {
// stub
});
fs.writeJsonSync(file, object, writeOptions);
fs.writeJSONSync(file, object, writeOptions);
fs.ensureDir(path).then(() => {
// stub
});
fs.ensureDir(path, errorCallback);
fs.ensureDirSync(path);
fs.ensureFile(path).then(() => {
// stub
});
fs.ensureFile(path, errorCallback);
fs.ensureFileSync(path);
fs.ensureLink(path).then(() => {
// stub
});
fs.ensureLink(path, errorCallback);
fs.ensureLinkSync(path);
fs.ensureSymlink(path).then(() => {
// stub
});
fs.ensureSymlink(path, errorCallback);
fs.ensureSymlinkSync(path);
fs.emptyDir(path).then(() => {
// stub
});
fs.emptyDir(path, errorCallback);
fs.emptyDirSync(path);
fs.pathExists(path).then((_exist: boolean) => {
// stub
});
fs.pathExists(path, (_err: Error, _exists: boolean) => { });
const x: boolean = fs.pathExistsSync(path);
fs.rename(src, dest, errorCallback);
fs.renameSync(src, dest);
fs.truncate(path, len, errorCallback);
fs.truncateSync(path, len);
fs.chown(path, uid, gid, errorCallback);
fs.chownSync(path, uid, gid);
fs.fchown(fd, uid, gid, errorCallback);
fs.fchownSync(fd, uid, gid);
fs.lchown(path, uid, gid, errorCallback);
fs.lchownSync(path, uid, gid);
fs.chmod(path, modeNum, errorCallback);
fs.chmod(path, modeStr, errorCallback);
fs.chmodSync(path, modeNum);
fs.chmodSync(path, modeStr);
fs.fchmod(fd, modeNum, errorCallback);
fs.fchmod(fd, modeStr, errorCallback);
fs.fchmodSync(fd, modeNum);
fs.fchmodSync(fd, modeStr);
fs.lchmod(path, modeStr, errorCallback);
fs.lchmod(path, modeNum, errorCallback);
fs.lchmodSync(path, modeNum);
fs.lchmodSync(path, modeStr);
fs.statSync(path);
fs.lstatSync(path);
+227 -101
View File
@@ -1,9 +1,8 @@
// Type definitions for fs-extra 2.1
// Type definitions for fs-extra 3.0
// Project: https://github.com/jprichardson/node-fs-extra
// Definitions by: midknight41 <https://github.com/midknight41>, Brendan Forster <https://github.com/shiftkey>
// Definitions by: Alan Agius <https://github.com/alan-agius4>, midknight41 <https://github.com/midknight41>, Brendan Forster <https://github.com/shiftkey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Imported from: https://github.com/soywiz/typescript-node-definitions/fs-extra.d.ts
// TypeScript Version: 2.2
/// <reference types="node" />
@@ -11,123 +10,255 @@ import { Stats } from "fs";
export * from "fs";
export declare function copy(src: string, dest: string, callback?: (err: Error) => void): void;
export declare function copy(src: string, dest: string, filter: CopyFilter, callback?: (err: Error) => void): void;
export declare function copy(src: string, dest: string, options: CopyOptions, callback?: (err: Error) => void): void;
export function copy(src: string, dest: string, options?: CopyOptions): Promise<void>;
export function copy(src: string, dest: string, callback: (err: Error) => void): void;
export function copy(src: string, dest: string, options: CopyOptions, callback: (err: Error) => void): void;
export function copySync(src: string, dest: string, options?: CopyOptions): void;
export declare function copySync(src: string, dest: string): void;
export declare function copySync(src: string, dest: string, filter: CopyFilter): void;
export declare function copySync(src: string, dest: string, options: CopyOptions): void;
export function move(src: string, dest: string, options?: MoveOptions): Promise<void>;
export function move(src: string, dest: string, callback: (err: Error) => void): void;
export function move(src: string, dest: string, options: MoveOptions, callback: (err: Error) => void): void;
export function moveSync(src: string, dest: string, options?: MoveOptions): void;
export declare function move(src: string, dest: string, callback?: (err: Error) => void): void;
export declare function move(src: string, dest: string, options: MoveOptions, callback?: (err: Error) => void): void;
export function createFile(file: string): Promise<void>;
export function createFile(file: string, callback: (err: Error) => void): void;
export function createFileSync(file: string): void;
export declare function createFile(file: string, callback?: (err: Error) => void): void;
export declare function createFileSync(file: string): void;
export function ensureDir(path: string): Promise<void>;
export function ensureDir(path: string, callback: (err: Error) => void): void;
export function ensureDirSync(path: string): void;
export declare function mkdirs(dir: string, callback?: (err: Error) => void): void;
export declare function mkdirp(dir: string, callback?: (err: Error) => void): void;
export declare function mkdirs(dir: string, options?: MkdirOptions, callback?: (err: Error) => void): void;
export declare function mkdirp(dir: string, options?: MkdirOptions, callback?: (err: Error) => void): void;
export declare function mkdirsSync(dir: string, options?: MkdirOptions): void;
export declare function mkdirpSync(dir: string, options?: MkdirOptions): void;
export function mkdirs(dir: string): Promise<void>;
export function mkdirs(dir: string, callback: (err: Error) => void): void;
export function mkdirp(dir: string): Promise<void>;
export function mkdirp(dir: string, callback: (err: Error) => void): void;
export function mkdirsSync(dir: string): void;
export function mkdirpSync(dir: string): void;
export declare function outputFile(file: string, data: any, callback?: (err: Error) => void): void;
export declare function outputFileSync(file: string, data: any): void;
export function outputFile(file: string, data: any): Promise<void>;
export function outputFile(file: string, data: any, callback: (err: Error) => void): void;
export function outputFileSync(file: string, data: any): void;
export declare function outputJson(file: string, data: any, callback?: (err: Error) => void): void;
export declare function outputJSON(file: string, data: any, callback?: (err: Error) => void): void;
export declare function outputJsonSync(file: string, data: any): void;
export declare function outputJSONSync(file: string, data: any): void;
export function readJson(file: string, options?: ReadOptions): Promise<any>;
export function readJson(file: string, callback: (err: Error, jsonObject: any) => void): void;
export function readJson(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void;
export function readJSON(file: string, options?: ReadOptions): Promise<any>;
export function readJSON(file: string, callback: (err: Error, jsonObject: any) => void): void;
export function readJSON(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void;
export declare function readJson(file: string, callback: (err: Error, jsonObject: any) => void): void;
export declare function readJson(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void;
export declare function readJSON(file: string, callback: (err: Error, jsonObject: any) => void): void;
export declare function readJSON(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void;
export function readJsonSync(file: string, options?: ReadOptions): any;
export function readJSONSync(file: string, options?: ReadOptions): any;
export declare function readJsonSync(file: string, options?: ReadOptions): any;
export declare function readJSONSync(file: string, options?: ReadOptions): any;
export function remove(dir: string): Promise<void>;
export function remove(dir: string, callback: (err: Error) => void): void;
export function removeSync(dir: string): void;
export declare function remove(dir: string, callback?: (err: Error) => void): void;
export declare function removeSync(dir: string): void;
export function outputJSON(file: string, data: any, options?: WriteOptions): Promise<void>;
export function outputJSON(file: string, data: any, options: WriteOptions, callback: (err: Error) => void): void;
export function outputJSON(file: string, data: any, callback: (err: Error) => void): void;
export function outputJson(file: string, data: any, options?: WriteOptions): Promise<void>;
export function outputJson(file: string, data: any, options: WriteOptions, callback: (err: Error) => void): void;
export function outputJson(file: string, data: any, callback: (err: Error) => void): void;
export function outputJsonSync(file: string, data: any, options?: WriteOptions): void;
export function outputJSONSync(file: string, data: any, options?: WriteOptions): void;
export declare function writeJson(file: string, object: any, callback?: (err: Error) => void): void;
export declare function writeJson(file: string, object: any, options?: WriteOptions, callback?: (err: Error) => void): void;
export declare function writeJSON(file: string, object: any, callback?: (err: Error) => void): void;
export declare function writeJSON(file: string, object: any, options?: WriteOptions, callback?: (err: Error) => void): void;
export function writeJSON(file: string, object: any, options?: WriteOptions): Promise<void>;
export function writeJSON(file: string, object: any, callback: (err: Error) => void): void;
export function writeJSON(file: string, object: any, options: WriteOptions, callback: (err: Error) => void): void;
export function writeJson(file: string, object: any, options?: WriteOptions): Promise<void>;
export function writeJson(file: string, object: any, callback: (err: Error) => void): void;
export function writeJson(file: string, object: any, options: WriteOptions, callback: (err: Error) => void): void;
export declare function writeJsonSync(file: string, object: any, options?: WriteOptions): void;
export declare function writeJSONSync(file: string, object: any, options?: WriteOptions): void;
export function writeJsonSync(file: string, object: any, options?: WriteOptions): void;
export function writeJSONSync(file: string, object: any, options?: WriteOptions): void;
export declare function ensureDir(path: string, callback: (err: Error) => void): void;
export declare function ensureDirSync(path: string): void;
export function ensureFile(path: string): Promise<void>;
export function ensureFile(path: string, callback: (err: Error) => void): void;
export function ensureFileSync(path: string): void;
export declare function ensureFile(path: string, callback: (err: Error) => void): void;
export declare function ensureFileSync(path: string): void;
export function ensureLink(path: string): Promise<void>;
export function ensureLink(path: string, callback: (err: Error) => void): void;
export function ensureLinkSync(path: string): void;
export declare function ensureLink(path: string, callback: (err: Error) => void): void;
export declare function ensureLinkSync(path: string): void;
export function ensureSymlink(path: string): Promise<void>;
export function ensureSymlink(path: string, callback: (err: Error) => void): void;
export function ensureSymlinkSync(path: string): void;
export declare function ensureSymlink(path: string, callback: (err: Error) => void): void;
export declare function ensureSymlinkSync(path: string): void;
export function emptyDir(path: string): Promise<void>;
export function emptyDir(path: string, callback: (err: Error) => void): void;
export function emptyDirSync(path: string): void;
export declare function emptyDir(path: string, callback?: (err: Error) => void): void;
export declare function emptyDirSync(path: string): boolean;
export function pathExists(path: string): Promise<boolean>;
export function pathExists(path: string, callback: (err: Error, exists: boolean) => void): void;
export function pathExistsSync(path: string): boolean;
export interface WalkEventEmitter extends NodeJS.ReadableStream {
on(event: 'data', callback: (file: WalkEventFile) => void): this;
on(event: 'readable', callback: (this: PathEntryStream) => void): this;
on(event: 'error', callback: (error: Error, item: PathEntry) => void): this;
on(event: 'end', callback: () => void): this;
on(event: string | symbol, callback: Function): this;
}
// fs async methods
// copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v6/index.d.ts
export interface WalkEventFile {
/** Tests a user's permissions for the file specified by path. */
export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void;
export function access(path: string | Buffer, mode?: number): Promise<void>;
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number | string; flag?: string; }, callback: (err: NodeJS.ErrnoException) => void): void;
export function appendFile(filename: string, data: any, callback: (err: NodeJS.ErrnoException) => void): void;
export function appendFile(filename: string, data: any, options?: { encoding?: string; mode?: number | string; flag?: string; }): Promise<void>;
export function chmod(path: string | Buffer, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function chmod(path: string | Buffer, mode: string | number): Promise<void>;
export function chown(path: string | Buffer, uid: number, gid: number): Promise<void>;
export function chown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function close(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function close(fd: number): Promise<void>;
export function fchmod(fd: number, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function fchmod(fd: number, mode: string | number): Promise<void>;
export function fchown(fd: number, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function fchown(fd: number, uid: number, gid: number): Promise<void>;
export function fdatasync(fd: number, callback: () => void): void;
export function fdatasync(fd: number): Promise<void>;
export function fstat(fd: number, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
export function fstat(fd: number): Promise<Stats>;
export function fsync(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function fsync(fd: number): Promise<void>;
export function ftruncate(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function ftruncate(fd: number, len: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function ftruncate(fd: number, len?: number): Promise<void>;
export function futimes(fd: number, atime: number, mtime: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function futimes(fd: number, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException) => void): void;
export function futimes(fd: number, atime: number, mtime: number): Promise<void>;
export function futimes(fd: number, atime: Date, mtime: Date): Promise<void>;
export function lchown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function lchown(path: string | Buffer, uid: number, gid: number): Promise<void>;
export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void;
export function link(srcpath: string | Buffer, dstpath: string | Buffer): Promise<void>;
export function lstat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
export function lstat(path: string | Buffer): Promise<Stats>;
/**
* Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
*
* @param path
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function mkdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void;
/**
* Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
*
* @param path
* @param mode
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function mkdir(path: string | Buffer, mode: number | string, callback: (err?: NodeJS.ErrnoException) => void): void;
export function mkdir(path: string | Buffer): Promise<void>;
export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
export function open(path: string | Buffer, flags: string | number, mode?: number): Promise<number>;
export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null, callback: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null): Promise<[number, Buffer]>;
export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
export function readFile(filename: string, options: { flag?: string; } | { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
export function readFile(filename: string, options: { flag?: string; } | { encoding: string; flag?: string; }): Promise<string>;
// tslint:disable-next-line:unified-signatures
export function readFile(filename: string, encoding: string): Promise<string>;
export function readFile(filename: string): Promise<Buffer>;
export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void;
export function readdir(path: string | Buffer): Promise<string[]>;
export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException, linkString: string) => any): void;
export function readlink(path: string | Buffer): Promise<string>;
export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
export function realpath(path: string | Buffer, cache?: { [path: string]: string }): Promise<string>;
export function rename(oldPath: string, newPath: string, callback: (err?: NodeJS.ErrnoException) => void): void;
export function rename(oldPath: string, newPath: string): Promise<void>;
/**
* Asynchronous rmdir - removes the directory specified in {path}
*
* @param path
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function rmdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void;
export function rmdir(path: string | Buffer): Promise<void>;
export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
export function stat(path: string | Buffer): Promise<Stats>;
export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: string, callback: (err?: NodeJS.ErrnoException) => void): void;
export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): Promise<void>;
export function truncate(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void;
export function truncate(path: string | Buffer, len: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function truncate(path: string | Buffer, len?: number): Promise<void>;
/**
* Asynchronous unlink - deletes the file specified in {path}
*
* @param path
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function unlink(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void;
export function unlink(path: string | Buffer): Promise<void>;
export function utimes(path: string | Buffer, atime: number, mtime: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException) => void): void;
export function utimes(path: string | Buffer, atime: number, mtime: number): Promise<void>;
export function utimes(path: string | Buffer, atime: Date, mtime: Date): Promise<void>;
export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number | null, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
export function write(fd: number, buffer: Buffer, offset: number, length: number, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
export function write(fd: number, data: any, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, data: any, offset: number, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, data: any, offset: number, encoding: string, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, buffer: Buffer, offset: number, length: number, position?: number | null): Promise<[number, Buffer]>;
export function write(fd: number, data: any, offset: number, encoding?: string): Promise<[number, string]>;
export function writeFile(filename: string, data: any, callback: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): Promise<void>;
/**
* Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
*
* @param prefix
* @param callback The created folder path is passed as a string to the callback's second parameter.
*/
export function mkdtemp(prefix: string, callback?: (err: NodeJS.ErrnoException, folder: string) => void): void;
export function mkdtemp(prefix: string): Promise<string>;
export interface PathEntry {
path: string;
stats: Stats;
}
export interface WalkOptions {
/**
* Control how results are enumerated from `readdir`:
* - 'shift' will return the first element from the array.
* - 'pop' will return the last element from the array.
*
* If not specified, the default behaviour is 'shift'
*/
queueMethod?: 'pop' | 'shift';
/**
* Provide a function to sort the paths before they are enumerated
*/
pathSorter?: (left: string, right: string) => number;
/**
* An optional object to override the default `fs` APIs for testing purposes
*/
fs?: Object;
/**
* Provide a function to exclude certain file paths. The function should
* return true when the element should be kept, and false otherwise.
*/
filter?: (path: string, index: number, array: Array<PathEntry>) => boolean;
export interface PathEntryStream {
read(): PathEntry | null;
}
export type PathEntry = {
path: string;
stats: Stats;
}
export type PathEntryStream = {
read(): PathEntry | null
}
export interface CopyFilterFunction {
(src: string): boolean
}
export type CopyFilterFunction = (src: string) => boolean;
export type CopyFilter = CopyFilterFunction | RegExp;
export interface CopyOptions {
clobber?: boolean;
dereference?: boolean;
overwrite?: boolean;
preserveTimestamps?: boolean;
@@ -137,28 +268,23 @@ export interface CopyOptions {
}
export interface MoveOptions {
clobber? : boolean;
overwrite?: boolean;
limit?: number;
}
export interface ReadOptions {
throws?: boolean;
fs?: Object;
fs?: object;
reviver?: any;
encoding?: string;
flag?: string;
}
export interface WriteOptions {
fs?: Object;
fs?: object;
replacer?: any;
spaces?: number;
encoding?: string;
flag?: string;
mode?: number;
}
export interface MkdirOptions {
fs?: any;
mode?: number;
}
+21 -21
View File
@@ -1,22 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"fs-extra-tests.ts"
]
}
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"fs-extra-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}