From d77027e8ae14f1d64b5e2dd78fe37b46e33ae996 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 11 Dec 2017 20:12:20 +0100 Subject: [PATCH 1/4] feat(fs extra): update APi to match `fs-extra 5.0.0` --- types/fs-extra/fs-extra-tests.ts | 18 ++---------------- types/fs-extra/index.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/types/fs-extra/fs-extra-tests.ts b/types/fs-extra/fs-extra-tests.ts index 1af094260d..50d594e1a4 100644 --- a/types/fs-extra/fs-extra-tests.ts +++ b/types/fs-extra/fs-extra-tests.ts @@ -52,17 +52,9 @@ fs.copy(src, dest, }, errorCallback ); -fs.copy(src, dest, - { - overwrite: true, - preserveTimestamps: true, - filter: /.*/ - }, - errorCallback -); + fs.copySync(src, dest); fs.copySync(src, dest, { filter: (src: string, dest: string) => false }); -fs.copySync(src, dest, { filter: /.*/ }); fs.copySync(src, dest, { overwrite: true, @@ -70,13 +62,7 @@ fs.copySync(src, dest, filter: (src: string, dest: string) => false } ); -fs.copySync(src, dest, - { - overwrite: true, - preserveTimestamps: true, - filter: /.*/ - } -); + fs.createFile(file).then(() => { // stub }); diff --git a/types/fs-extra/index.d.ts b/types/fs-extra/index.d.ts index 575df86b4d..f556afa82f 100644 --- a/types/fs-extra/index.d.ts +++ b/types/fs-extra/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for fs-extra 4.0 +// Type definitions for fs-extra 5.0 // Project: https://github.com/jprichardson/node-fs-extra // Definitions by: Alan Agius , // midknight41 , @@ -254,7 +254,7 @@ export interface PathEntryStream { read(): PathEntry | null; } -export type CopyFilter = ((src: string, dest: string) => boolean) | RegExp; +export type CopyFilter = (src: string, dest: string) => boolean; export type SymlinkType = "dir" | "file"; From 57c524c9bdef2d69245e5d414b284846bd78005e Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 12 Dec 2017 19:14:23 +0100 Subject: [PATCH 2/4] feat(fs extra): update APi to match `fs-extra 5.0.0` --- types/fs-extra-promise-es6/tsconfig.json | 5 + types/fs-extra-promise/tsconfig.json | 5 + types/fs-extra/fs-extra-tests.ts | 18 +- types/fs-extra/index.d.ts | 4 +- types/fs-extra/v4/fs-extra-tests.ts | 230 +++++++++++++++++ types/fs-extra/v4/index.d.ts | 303 +++++++++++++++++++++++ types/fs-extra/v4/tsconfig.json | 28 +++ types/fs-extra/v4/tslint.json | 3 + 8 files changed, 578 insertions(+), 18 deletions(-) create mode 100644 types/fs-extra/v4/fs-extra-tests.ts create mode 100644 types/fs-extra/v4/index.d.ts create mode 100644 types/fs-extra/v4/tsconfig.json create mode 100644 types/fs-extra/v4/tslint.json diff --git a/types/fs-extra-promise-es6/tsconfig.json b/types/fs-extra-promise-es6/tsconfig.json index b7e6f664f2..c9e19d0f7f 100644 --- a/types/fs-extra-promise-es6/tsconfig.json +++ b/types/fs-extra-promise-es6/tsconfig.json @@ -12,6 +12,11 @@ "typeRoots": [ "../" ], + "paths": { + "fs-extra": [ + "fs-extra/v4" + ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/fs-extra-promise/tsconfig.json b/types/fs-extra-promise/tsconfig.json index e0f6cc3450..4a4fc0f60b 100644 --- a/types/fs-extra-promise/tsconfig.json +++ b/types/fs-extra-promise/tsconfig.json @@ -12,6 +12,11 @@ "typeRoots": [ "../" ], + "paths": { + "fs-extra": [ + "fs-extra/v4" + ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/types/fs-extra/fs-extra-tests.ts b/types/fs-extra/fs-extra-tests.ts index 1af094260d..50d594e1a4 100644 --- a/types/fs-extra/fs-extra-tests.ts +++ b/types/fs-extra/fs-extra-tests.ts @@ -52,17 +52,9 @@ fs.copy(src, dest, }, errorCallback ); -fs.copy(src, dest, - { - overwrite: true, - preserveTimestamps: true, - filter: /.*/ - }, - errorCallback -); + fs.copySync(src, dest); fs.copySync(src, dest, { filter: (src: string, dest: string) => false }); -fs.copySync(src, dest, { filter: /.*/ }); fs.copySync(src, dest, { overwrite: true, @@ -70,13 +62,7 @@ fs.copySync(src, dest, filter: (src: string, dest: string) => false } ); -fs.copySync(src, dest, - { - overwrite: true, - preserveTimestamps: true, - filter: /.*/ - } -); + fs.createFile(file).then(() => { // stub }); diff --git a/types/fs-extra/index.d.ts b/types/fs-extra/index.d.ts index 575df86b4d..f556afa82f 100644 --- a/types/fs-extra/index.d.ts +++ b/types/fs-extra/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for fs-extra 4.0 +// Type definitions for fs-extra 5.0 // Project: https://github.com/jprichardson/node-fs-extra // Definitions by: Alan Agius , // midknight41 , @@ -254,7 +254,7 @@ export interface PathEntryStream { read(): PathEntry | null; } -export type CopyFilter = ((src: string, dest: string) => boolean) | RegExp; +export type CopyFilter = (src: string, dest: string) => boolean; export type SymlinkType = "dir" | "file"; diff --git a/types/fs-extra/v4/fs-extra-tests.ts b/types/fs-extra/v4/fs-extra-tests.ts new file mode 100644 index 0000000000..1af094260d --- /dev/null +++ b/types/fs-extra/v4/fs-extra-tests.ts @@ -0,0 +1,230 @@ +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 readOptions: fs.ReadOptions = { + reviver: {} +}; +const writeOptions: fs.WriteOptions = { + 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, { filter: (src: string, dest: string) => false }, errorCallback); +fs.copy(src, dest, + { + overwrite: true, + preserveTimestamps: true, + filter: (src: string, dest: string) => false + }, + errorCallback +); +fs.copy(src, dest, + { + overwrite: true, + preserveTimestamps: true, + filter: /.*/ + }, + errorCallback +); +fs.copySync(src, dest); +fs.copySync(src, dest, { filter: (src: string, dest: string) => false }); +fs.copySync(src, dest, { filter: /.*/ }); +fs.copySync(src, dest, + { + overwrite: true, + preserveTimestamps: true, + filter: (src: string, dest: string) => false + } +); +fs.copySync(src, dest, + { + 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.mkdirsSync(dir); +fs.mkdirp(dir, errorCallback); +fs.mkdirpSync(dir); + +fs.outputFile(file, data).then(() => { + // stub +}); +fs.outputFile(file, data, errorCallback); +fs.outputFileSync(file, data); + +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).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, path).then(() => { + // stub +}); +fs.ensureLink(path, path, errorCallback); +fs.ensureLinkSync(path, path); +fs.ensureSymlink(path, path, "file").then(() => { + // stub +}); +fs.ensureSymlink(path, path, errorCallback); +fs.ensureSymlinkSync(path, 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); + +fs.read(0, new Buffer(""), 0, 0, null).then(x => { + const a = x.buffer; + const b = x.bytesRead; +}); + +fs.write(0, new Buffer(""), 0, 0, null).then(x => { + const a = x.buffer; + const b = x.bytesWritten; +}); + +// $ExpectType Promise +fs.writeFile("foo.txt", "i am foo", { encoding: "utf-8" }); + +// $ExpectType Promise +fs.mkdtemp("foo"); diff --git a/types/fs-extra/v4/index.d.ts b/types/fs-extra/v4/index.d.ts new file mode 100644 index 0000000000..575df86b4d --- /dev/null +++ b/types/fs-extra/v4/index.d.ts @@ -0,0 +1,303 @@ +// Type definitions for fs-extra 4.0 +// Project: https://github.com/jprichardson/node-fs-extra +// Definitions by: Alan Agius , +// midknight41 , +// Brendan Forster , +// Mees van Dijk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +import { Stats } from "fs"; + +export * from "fs"; + +export function copy(src: string, dest: string, options?: CopyOptions): Promise; +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 function move(src: string, dest: string, options?: MoveOptions): Promise; +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 function createFile(file: string): Promise; +export function createFile(file: string, callback: (err: Error) => void): void; +export function createFileSync(file: string): void; + +export function ensureDir(path: string): Promise; +export function ensureDir(path: string, callback: (err: Error) => void): void; +export function ensureDirSync(path: string): void; + +export function mkdirs(dir: string): Promise; +export function mkdirs(dir: string, callback: (err: Error) => void): void; +export function mkdirp(dir: string): Promise; +export function mkdirp(dir: string, callback: (err: Error) => void): void; +export function mkdirsSync(dir: string): void; +export function mkdirpSync(dir: string): void; + +export function outputFile(file: string, data: any, options?: WriteFileOptions | string): Promise; +export function outputFile(file: string, data: any, callback: (err: Error) => void): void; +export function outputFile(file: string, data: any, options: WriteFileOptions | string, callback: (err: Error) => void): void; +export function outputFileSync(file: string, data: any, options?: WriteFileOptions | string): void; + +export function readJson(file: string, options?: ReadOptions): Promise; +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; +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 readJsonSync(file: string, options?: ReadOptions): any; +export function readJSONSync(file: string, options?: ReadOptions): any; + +export function remove(dir: string): Promise; +export function remove(dir: string, callback: (err: Error) => void): void; +export function removeSync(dir: string): void; + +export function outputJSON(file: string, data: any, options?: WriteOptions): Promise; +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; +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 function writeJSON(file: string, object: any, options?: WriteOptions): Promise; +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; +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 writeJsonSync(file: string, object: any, options?: WriteOptions): void; +export function writeJSONSync(file: string, object: any, options?: WriteOptions): void; + +export function ensureFile(path: string): Promise; +export function ensureFile(path: string, callback: (err: Error) => void): void; +export function ensureFileSync(path: string): void; + +export function ensureLink(src: string, dest: string): Promise; +export function ensureLink(src: string, dest: string, callback: (err: Error) => void): void; +export function ensureLinkSync(src: string, dest: string): void; + +export function ensureSymlink(src: string, dest: string, type?: SymlinkType): Promise; +export function ensureSymlink(src: string, dest: string, type: SymlinkType, callback: (err: Error) => void): void; +export function ensureSymlink(src: string, dest: string, callback: (err: Error) => void): void; +export function ensureSymlinkSync(src: string, dest: string, type?: SymlinkType): void; + +export function emptyDir(path: string): Promise; +export function emptyDir(path: string, callback: (err: Error) => void): void; +export function emptyDirSync(path: string): void; + +export function pathExists(path: string): Promise; +export function pathExists(path: string, callback: (err: Error, exists: boolean) => void): void; +export function pathExistsSync(path: string): boolean; + +// fs async methods +// copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v6/index.d.ts + +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; + +export function appendFile(file: string | Buffer | number, data: any, options: { encoding?: string; mode?: number | string; flag?: string; }, + callback: (err: NodeJS.ErrnoException) => void): void; +export function appendFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void; +export function appendFile(file: string | Buffer | number, data: any, options?: { encoding?: string; mode?: number | string; flag?: string; }): Promise; + +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; + +export function chown(path: string | Buffer, uid: number, gid: number): Promise; +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; + +export function fchmod(fd: number, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void; +export function fchmod(fd: number, mode: string | number): Promise; + +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; + +export function fdatasync(fd: number, callback: () => void): void; +export function fdatasync(fd: number): Promise; + +export function fstat(fd: number, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void; +export function fstat(fd: number): Promise; + +export function fsync(fd: number, callback: (err: NodeJS.ErrnoException) => void): void; +export function fsync(fd: number): Promise; + +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; + +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; +export function futimes(fd: number, atime: Date, mtime: Date): Promise; + +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; + +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; + +export function lstat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void; +export function lstat(path: string | Buffer): Promise; + +/** + * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @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 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; + +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; + +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; + +export function readFile(file: string | Buffer | number, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; +export function readFile(file: string | Buffer | number, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; +export function readFile(file: string | Buffer | number, options: { flag?: string; } | { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; +export function readFile(file: string | Buffer | number, options: { flag?: string; } | { encoding: string; flag?: string; }): Promise; +// tslint:disable-next-line:unified-signatures +export function readFile(file: string | Buffer | number, encoding: string): Promise; +export function readFile(file: string | Buffer | number): Promise; + +export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void; +export function readdir(path: string | Buffer): Promise; + +export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException, linkString: string) => any): void; +export function readlink(path: string | Buffer): Promise; + +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; + +export function rename(oldPath: string, newPath: string, callback: (err: NodeJS.ErrnoException) => void): void; +export function rename(oldPath: string, newPath: string): Promise; + +/** + * Asynchronous rmdir - removes the directory specified in {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; + +export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void; +export function stat(path: string | Buffer): Promise; + +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; + +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; + +/** + * Asynchronous unlink - deletes the file specified in {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; + +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; +export function utimes(path: string | Buffer, atime: Date, mtime: Date): Promise; + +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; +export function write(fd: number, data: any, offset: number, encoding?: string): Promise; + +export function writeFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void; +export function writeFile(file: string | Buffer | number, data: any, options?: WriteFileOptions | string): Promise; +export function writeFile(file: string | Buffer | number, data: any, options: WriteFileOptions | string, callback: (err: NodeJS.ErrnoException) => void): 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 callback The created folder path is passed as a string to the callback's second parameter. + */ +export function mkdtemp(prefix: string): Promise; +export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException, folder: string) => void): void; + +export interface PathEntry { + path: string; + stats: Stats; +} + +export interface PathEntryStream { + read(): PathEntry | null; +} + +export type CopyFilter = ((src: string, dest: string) => boolean) | RegExp; + +export type SymlinkType = "dir" | "file"; + +export interface CopyOptions { + dereference?: boolean; + overwrite?: boolean; + preserveTimestamps?: boolean; + errorOnExist?: boolean; + filter?: CopyFilter; + recursive?: boolean; +} + +export interface MoveOptions { + overwrite?: boolean; + limit?: number; +} + +export interface ReadOptions { + throws?: boolean; + fs?: object; + reviver?: any; + encoding?: string; + flag?: string; +} + +export interface WriteFileOptions { + encoding?: string; + flag?: string; + mode?: number; +} + +export interface WriteOptions extends WriteFileOptions { + fs?: object; + replacer?: any; + spaces?: number | string; +} + +export interface ReadResult { + bytesRead: number; + buffer: Buffer; +} + +export interface WriteResult { + bytesWritten: number; + buffer: Buffer; +} diff --git a/types/fs-extra/v4/tsconfig.json b/types/fs-extra/v4/tsconfig.json new file mode 100644 index 0000000000..80435f4ede --- /dev/null +++ b/types/fs-extra/v4/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "fs-extra": [ + "fs-extra/v4" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fs-extra-tests.ts" + ] +} \ No newline at end of file diff --git a/types/fs-extra/v4/tslint.json b/types/fs-extra/v4/tslint.json new file mode 100644 index 0000000000..53ebf76f7e --- /dev/null +++ b/types/fs-extra/v4/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../dtslint/dt.json" +} From 3a38158439c88fcbe08976af9cc7a1266e6cb4c3 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 12 Dec 2017 19:21:38 +0100 Subject: [PATCH 3/4] fs-extra-promise: remove extra path --- types/fs-extra-promise-es6/tsconfig.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/types/fs-extra-promise-es6/tsconfig.json b/types/fs-extra-promise-es6/tsconfig.json index c9e19d0f7f..b7e6f664f2 100644 --- a/types/fs-extra-promise-es6/tsconfig.json +++ b/types/fs-extra-promise-es6/tsconfig.json @@ -12,11 +12,6 @@ "typeRoots": [ "../" ], - "paths": { - "fs-extra": [ - "fs-extra/v4" - ] - }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true From 9c777743050abf8df317aec53cbd79b2423c8dce Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 12 Dec 2017 19:25:40 +0100 Subject: [PATCH 4/4] fix tslint path --- types/fs-extra/v4/tslint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/fs-extra/v4/tslint.json b/types/fs-extra/v4/tslint.json index 53ebf76f7e..d88586e5bd 100644 --- a/types/fs-extra/v4/tslint.json +++ b/types/fs-extra/v4/tslint.json @@ -1,3 +1,3 @@ { - "extends": "../dtslint/dt.json" + "extends": "dtslint/dt.json" }