fix node fs.watch (#9446)

* fix node fs.watch

* add fs.watch test
This commit is contained in:
LongYinan
2016-06-03 00:42:52 +09:00
committed by Masahiro Wakame
parent e41aa98022
commit 5b670ebf34
2 changed files with 18 additions and 1 deletions
+16
View File
@@ -138,6 +138,22 @@ fs.mkdtemp('/tmp/foo-', (err, folder) => {
var tempDir: string;
tempDir = fs.mkdtempSync('/tmp/foo-');
fs.watch('/tmp/foo-', (event, filename) => {
console.log(event, filename);
});
fs.watch('/tmp/foo-', 'utf8', (event, filename) => {
console.log(event, filename);
});
fs.watch('/tmp/foo-', {
recursive: true,
persistent: true,
encoding: 'utf8'
}, (event, filename) => {
console.log(event, filename);
});
///////////////////////////////////////////////////////
/// Buffer tests : https://nodejs.org/api/buffer.html
///////////////////////////////////////////////////////
+2 -1
View File
@@ -1599,7 +1599,8 @@ declare module "fs" {
export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void;
export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void;
export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher;
export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher;
export function watch(filename: string, encoding: string, listener?: (event: string, filename: string) => any): FSWatcher;
export function watch(filename: string, options: { persistent?: boolean; recursive?: boolean; encoding?: string }, listener?: (event: string, filename: string) => any): FSWatcher;
export function exists(path: string | Buffer, callback?: (exists: boolean) => void): void;
export function existsSync(path: string | Buffer): boolean;
/** Constant for fs.access(). File is visible to the calling process. */