Add missing walk() method to fs-extra (#13070)

* Add walk() to fs-extra

* Fix some indentation in fs-extra
This commit is contained in:
Tim Perry 2017-01-06 16:04:10 +01:00 committed by Andy
parent 602a847455
commit 17264e0456
2 changed files with 30 additions and 7 deletions

View File

@ -101,3 +101,12 @@ fs.ensureSymlink(path, errorCallback);
fs.ensureSymlinkSync(path);
fs.emptyDir(path, errorCallback);
fs.emptyDirSync(path);
var items: string[];
fs.walk("my-path")
.on('data', function (item) {
items.push(item.path);
})
.on('end', function () {
console.dir(items);
});

28
fs-extra/index.d.ts vendored
View File

@ -8,6 +8,7 @@
/// <reference types="node" />
import * as stream from 'stream';
import { Stats } from "fs";
export * from "fs";
export declare function copy(src: string, dest: string, callback?: (err: Error) => void): void;
@ -72,8 +73,21 @@ export declare function ensureSymlinkSync(path: string): void;
export declare function emptyDir(path: string, callback?: (err: Error) => void): void;
export declare function emptyDirSync(path: string): boolean;
export interface CopyFilterFunction {
export interface WalkEventEmitter {
on(event: 'data', callback: (file: WalkEventFile) => void): WalkEventEmitter;
on(event: 'end', callback: () => void): WalkEventEmitter;
on(event: string, callback: Function): WalkEventEmitter;
}
export interface WalkEventFile {
path: string;
stats: Stats;
}
export function walk(path: string, options?: {}): WalkEventEmitter;
export interface CopyFilterFunction {
(src: string): boolean
}
@ -86,11 +100,11 @@ export interface CopyOptions {
filter?: CopyFilter
recursive?: boolean
}
export interface MoveOptions {
clobber? : boolean;
limit?: number;
}
export interface MoveOptions {
clobber? : boolean;
limit?: number;
}
export interface MoveOptions {
clobber? : boolean;