diff --git a/fs-extra/fs-extra-tests.ts b/fs-extra/fs-extra-tests.ts index c1785f851d..a31df8cfd7 100644 --- a/fs-extra/fs-extra-tests.ts +++ b/fs-extra/fs-extra-tests.ts @@ -2,50 +2,16 @@ /// import fs = require('fs-extra'); -import stream = require('stream'); -var stats: fs.Stats; -var str: string; -var strArr: string[]; -var bool: boolean; -var num: number; var src: string; var dest: string; var file: string; -var filename: string; var dir: string; var path: string; var data: any; var object: Object; -var buffer: NodeBuffer; -var modeNum: number; -var modeStr: string; -var encoding: string; -var type: string; -var flags: string; -var srcpath: string; -var dstpath: string; -var oldPath: string; -var newPath: string; -var cache: string; -var offset: number; -var length: number; -var position: number; -var cacheBool: boolean; -var cacheStr: string; -var fd: number; -var len: number; -var uid: number; -var gid: number; -var atime: number; -var mtime: number; -var statsCallback: (err: Error, stats: fs.Stats) => void; var errorCallback: (err: Error) => void; var openOpts: fs.OpenOptions; -var watcher: fs.FSWatcher; -var readStreeam: stream.Readable; -var writeStream: stream.Writable; -var outputStream: stream.Writable; fs.copy(src, dest, errorCallback); fs.copy(src, dest, (src: string) => { @@ -125,130 +91,6 @@ fs.writeJSON(file, object, openOpts, errorCallback); fs.writeJsonSync(file, object, openOpts); fs.writeJSONSync(file, object, openOpts); -fs.rename(oldPath, newPath, errorCallback); -fs.renameSync(oldPath, newPath); -fs.truncate(fd, len, errorCallback); -fs.truncateSync(fd, 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.stat(path, statsCallback); -fs.lstat(path, statsCallback); -fs.fstat(fd, statsCallback); -stats = fs.statSync(path); -stats = fs.lstatSync(path); -stats = fs.fstatSync(fd); -fs.link(srcpath, dstpath, errorCallback); -fs.linkSync(srcpath, dstpath); -fs.symlink(srcpath, dstpath, type, errorCallback); -fs.symlinkSync(srcpath, dstpath, type); -fs.readlink(path, (err: Error, linkString: string) => { - -}); -fs.realpath(path, (err: Error, resolvedPath: string) => { - -}); -fs.realpath(path, cache, (err: Error, resolvedPath: string) => { - -}); -str = fs.realpathSync(path, cacheBool); -fs.unlink(path, errorCallback); -fs.unlinkSync(path); -fs.rmdir(path, errorCallback); -fs.rmdirSync(path); -fs.mkdir(path, modeNum, errorCallback); -fs.mkdir(path, modeStr, errorCallback); -fs.mkdirSync(path, modeNum); -fs.mkdirSync(path, modeStr); -fs.readdir(path, (err: Error, files: string[]) => { - -}); -strArr = fs.readdirSync(path); -fs.close(fd, errorCallback); -fs.closeSync(fd); -fs.open(path, flags, modeStr, (err: Error, fd: number) => { - -}); -num = fs.openSync(path, flags, modeStr); -fs.utimes(path, atime, mtime, errorCallback); -fs.utimesSync(path, atime, mtime); -fs.futimes(fd, atime, mtime, errorCallback); -fs.futimesSync(fd, atime, mtime); -fs.fsync(fd, errorCallback); -fs.fsyncSync(fd); -fs.write(fd, buffer, offset, length, position, (err: Error, written: number, buffer: NodeBuffer) => { - -}); -num = fs.writeSync(fd, buffer, offset, length, position); -fs.read(fd, buffer, offset, length, position, (err: Error, bytesRead: number, buffer: NodeBuffer) => { - -}); -num = fs.readSync(fd, buffer, offset, length, position); -fs.readFile(filename, (err: Error, data: NodeBuffer) => { - -}); -fs.readFile(filename, encoding, (err: Error, data: string) => { - -}); -fs.readFile(filename, openOpts, (err: Error, data: string) => { - -}); -fs.readFile(filename, (err: Error, data: NodeBuffer) => { - -}); -buffer = fs.readFileSync(filename); -str = fs.readFileSync(filename, encoding); -str = fs.readFileSync(filename, openOpts); - -fs.writeFile(filename, data, errorCallback); -fs.writeFile(filename, data, encoding, errorCallback); -fs.writeFile(filename, data, openOpts, errorCallback); -fs.writeFileSync(filename, data); -fs.writeFileSync(filename, data, encoding); -fs.writeFileSync(filename, data, openOpts); - -fs.appendFile(filename, data, errorCallback); -fs.appendFile(filename, data, encoding, errorCallback); -fs.appendFile(filename, data, openOpts, errorCallback); -fs.appendFileSync(filename, data); -fs.appendFileSync(filename, data, encoding); -fs.appendFileSync(filename, data, openOpts); - -fs.watchFile(filename, { - curr: stats, - prev: stats -}); -fs.watchFile(filename, { - persistent: bool, - interval: num -}, { - curr: stats, - prev: stats -}); -fs.unwatchFile(filename); -watcher = fs.watch(filename, { persistent: bool }, (event: string, filename: string) => { - -}); -fs.exists(path, (exists: boolean) => { - -}); -bool = fs.existsSync(path); - fs.ensureDir(path, errorCallback); fs.ensureDirSync(path); fs.ensureFile(path, errorCallback); @@ -259,24 +101,3 @@ fs.ensureSymlink(path, errorCallback); fs.ensureSymlinkSync(path); fs.emptyDir(path, errorCallback); fs.emptyDirSync(path); - -readStreeam = fs.createReadStream(path); -readStreeam = fs.createReadStream(path, { - flags: str, - encoding: str, - fd: num, - mode: num, - bufferSize: num -}); -writeStream = fs.createWriteStream(path); -writeStream = fs.createWriteStream(path, { - flags: str, - encoding: str, - string: str -}); -outputStream = fs.createOutputStream(path); -outputStream = fs.createOutputStream(path, { - flags: str, - encoding: str, - string: str -}); diff --git a/fs-extra/fs-extra.d.ts b/fs-extra/fs-extra.d.ts index b133047dec..39656ce685 100644 --- a/fs-extra/fs-extra.d.ts +++ b/fs-extra/fs-extra.d.ts @@ -8,39 +8,8 @@ /// declare module "fs-extra" { - import stream = require("stream"); + export * from "fs"; - export interface Stats { - isFile(): boolean; - isDirectory(): boolean; - isBlockDevice(): boolean; - isCharacterDevice(): boolean; - isSymbolicLink(): boolean; - isFIFO(): boolean; - isSocket(): boolean; - dev: number; - ino: number; - mode: number; - nlink: number; - uid: number; - gid: number; - rdev: number; - size: number; - blksize: number; - blocks: number; - atime: Date; - mtime: Date; - ctime: Date; - } - - export interface FSWatcher { - close(): void; - } - - export class ReadStream extends stream.Readable { } - export class WriteStream extends stream.Writable { } - - //extended methods export function copy(src: string, dest: string, callback?: (err: Error) => void): void; export function copy(src: string, dest: string, filter: CopyFilter, callback?: (err: Error) => void): void; export function copy(src: string, dest: string, options: CopyOptions, callback?: (err: Error) => void): void; @@ -77,8 +46,6 @@ declare module "fs-extra" { export function remove(dir: string, callback?: (err: Error) => void): void; export function removeSync(dir: string): void; - // export function delete(dir: string, callback?: (err: Error) => void): void; - // export function deleteSync(dir: string): void; export function writeJson(file: string, object: any, callback?: (err: Error) => void): void; export function writeJson(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; @@ -88,98 +55,22 @@ declare module "fs-extra" { export function writeJsonSync(file: string, object: any, options?: OpenOptions): void; export function writeJSONSync(file: string, object: any, options?: OpenOptions): void; - export function rename(oldPath: string, newPath: string, callback?: (err: Error) => void): void; - export function renameSync(oldPath: string, newPath: string): void; - export function truncate(fd: number, len: number, callback?: (err: Error) => void): void; - export function truncateSync(fd: number, len: number): void; - export function chown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; - export function chownSync(path: string, uid: number, gid: number): void; - export function fchown(fd: number, uid: number, gid: number, callback?: (err: Error) => void): void; - export function fchownSync(fd: number, uid: number, gid: number): void; - export function lchown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; - export function lchownSync(path: string, uid: number, gid: number): void; - export function chmod(path: string, mode: number, callback?: (err: Error) => void): void; - export function chmod(path: string, mode: string, callback?: (err: Error) => void): void; - export function chmodSync(path: string, mode: number): void; - export function chmodSync(path: string, mode: string): void; - export function fchmod(fd: number, mode: number, callback?: (err: Error) => void): void; - export function fchmod(fd: number, mode: string, callback?: (err: Error) => void): void; - export function fchmodSync(fd: number, mode: number): void; - export function fchmodSync(fd: number, mode: string): void; - export function lchmod(path: string, mode: string, callback?: (err: Error) => void): void; - export function lchmod(path: string, mode: number, callback?: (err: Error) => void): void; - export function lchmodSync(path: string, mode: number): void; - export function lchmodSync(path: string, mode: string): void; - export function stat(path: string, callback?: (err: Error, stats: Stats) => void): void; - export function lstat(path: string, callback?: (err: Error, stats: Stats) => void): void; - export function fstat(fd: number, callback?: (err: Error, stats: Stats) => void): void; - export function statSync(path: string): Stats; - export function lstatSync(path: string): Stats; - export function fstatSync(fd: number): Stats; - export function link(srcpath: string, dstpath: string, callback?: (err: Error) => void): void; - export function linkSync(srcpath: string, dstpath: string): void; - export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err: Error) => void): void; - export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; - export function readlink(path: string, callback?: (err: Error, linkString: string) => void): void; - export function realpath(path: string, callback?: (err: Error, resolvedPath: string) => void): void; - export function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) => void): void; - export function realpathSync(path: string, cache?: boolean): string; - export function unlink(path: string, callback?: (err: Error) => void): void; - export function unlinkSync(path: string): void; - export function rmdir(path: string, callback?: (err: Error) => void): void; - export function rmdirSync(path: string): void; - export function mkdir(path: string, mode?: number, callback?: (err: Error) => void): void; - export function mkdir(path: string, mode?: string, callback?: (err: Error) => void): void; - export function mkdirSync(path: string, mode?: number): void; - export function mkdirSync(path: string, mode?: string): void; - export function readdir(path: string, callback?: (err: Error, files: string[]) => void ): void; - export function readdirSync(path: string): string[]; - export function close(fd: number, callback?: (err: Error) => void): void; - export function closeSync(fd: number): void; - export function open(path: string, flags: string, mode?: string, callback?: (err: Error, fs: number) => void): void; - export function openSync(path: string, flags: string, mode?: string): number; - export function utimes(path: string, atime: number, mtime: number, callback?: (err: Error) => void): void; - export function utimesSync(path: string, atime: number, mtime: number): void; - export function futimes(fd: number, atime: number, mtime: number, callback?: (err: Error) => void): void; - export function futimesSync(fd: number, atime: number, mtime: number): void; - export function fsync(fd: number, callback?: (err: Error) => void): void; - export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) => void): void; - export function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; - export function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void ): void; - export function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; - export function readFile(filename: string, encoding: string, callback: (err: Error, data: string) => void ): void; - export function readFile(filename: string, options: OpenOptions, callback: (err: Error, data: string) => void ): void; - export function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void ): void; - export function readFileSync(filename: string): NodeBuffer; - export function readFileSync(filename: string, encoding: string): string; - export function readFileSync(filename: string, options: OpenOptions): string; - export function writeFile(filename: string, data: any, encoding?: string, callback?: (err: Error) => void): void; - export function writeFile(filename: string, data: any, options?: OpenOptions, callback?: (err: Error) => void): void; - export function writeFileSync(filename: string, data: any, encoding?: string): void; - export function writeFileSync(filename: string, data: any, option?: OpenOptions): void; - export function appendFile(filename: string, data: any, encoding?: string, callback?: (err: Error) => void): void; - export function appendFile(filename: string, data: any,option?: OpenOptions, callback?: (err: Error) => void): void; - export function appendFileSync(filename: string, data: any, encoding?: string): void; - export function appendFileSync(filename: string, data: any, option?: OpenOptions): void; - export function watchFile(filename: string, listener: { curr: Stats; prev: Stats; }): void; - export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: { curr: Stats; prev: Stats; }): void; - export function unwatchFile(filename: string, listener?: Stats): void; - export function watch(filename: string, options?: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; - export function exists(path: string, callback?: (exists: boolean) => void ): void; - export function existsSync(path: string): boolean; export function ensureDir(path: string, cb: (err: Error) => void): void; export function ensureDirSync(path: string): void; + export function ensureFile(path: string, cb: (err: Error) => void): void; export function ensureFileSync(path: string): void; + export function ensureLink(path: string, cb: (err: Error) => void): void; export function ensureLinkSync(path: string): void; + export function ensureSymlink(path: string, cb: (err: Error) => void): void; export function ensureSymlinkSync(path: string): void; + export function emptyDir(path: string, callback?: (err: Error) => void): void; export function emptyDirSync(path: string): boolean; - export interface CopyFilterFunction { + export interface CopyFilterFunction { (src: string): boolean } @@ -188,6 +79,7 @@ declare module "fs-extra" { export interface CopyOptions { clobber?: boolean preserveTimestamps?: boolean + dereference?: boolean filter?: CopyFilter } @@ -200,20 +92,4 @@ declare module "fs-extra" { fs?: any; mode?: number; } - - export interface ReadStreamOptions { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - bufferSize?: number; - } - export interface WriteStreamOptions { - flags?: string; - encoding?: string; - string?: string; - } - export function createReadStream(path: string, options?: ReadStreamOptions): ReadStream; - export function createWriteStream(path: string, options?: WriteStreamOptions): WriteStream; - export function createOutputStream(path: string, options?: WriteStreamOptions): WriteStream; }