mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
chokidar: Change event type to string (#13572)
This commit is contained in:
parent
e91fc673f7
commit
1ca23b1980
@ -9,20 +9,25 @@ var watcher = chokidar.watch('file, dir, or glob', {
|
||||
|
||||
var log = console.log.bind(console);
|
||||
|
||||
let str: string;
|
||||
let any: any;
|
||||
let stats: fs.Stats;
|
||||
|
||||
watcher
|
||||
.on('add', function(path:string) { log('File', path, 'has been added'); })
|
||||
.on('addDir', function(path:string) { log('Directory', path, 'has been added'); })
|
||||
.on('change', function(path:string) { log('File', path, 'has been changed'); })
|
||||
.on('unlink', function(path:string) { log('File', path, 'has been removed'); })
|
||||
.on('unlinkDir', function(path:string) { log('Directory', path, 'has been removed'); })
|
||||
.on('error', function(error:any) { log('Error happened', error); })
|
||||
.on('ready', function() { log('Initial scan complete. Ready for changes.'); })
|
||||
.on('raw', function(event:Event, path:string, details:any) { log('Raw event info:', event, path, details); })
|
||||
.on('add', path => { str = path; })
|
||||
.on('addDir', path => { str = path; })
|
||||
.on('change', path => { str = path; })
|
||||
.on('unlink', path => { str = path; })
|
||||
.on('unlinkDir', path => { str = path; })
|
||||
.on('error', (error) => { any = error; })
|
||||
.on('ready', () => { })
|
||||
.on('raw', (event, path, details) => { str = event; str = path; any = details; })
|
||||
|
||||
// 'add', 'addDir' and 'change' events also receive stat() results as second
|
||||
// argument when available: http://nodejs.org/api/fs.html#fs_class_fs_stats
|
||||
watcher.on('change', function(path:string, stats:fs.Stats) {
|
||||
if (stats) console.log('File', path, 'changed size to', stats.size);
|
||||
watcher.on('change', (path, _stats) => {
|
||||
str = path;
|
||||
stats = _stats;
|
||||
});
|
||||
|
||||
// Watch new files.
|
||||
@ -36,6 +41,7 @@ watcher.unwatch('new-file*');
|
||||
watcher.close();
|
||||
|
||||
// One-liner
|
||||
require('chokidar').watch('.', {ignored: /[\/\\]\./}).on('all', function(event:string, path:string) {
|
||||
console.log(event, path);
|
||||
chokidar.watch('.', {ignored: /[\/\\]\./}).on('all', (event, path) => {
|
||||
str = event;
|
||||
str = path;
|
||||
});
|
||||
3
chokidar/index.d.ts
vendored
3
chokidar/index.d.ts
vendored
@ -18,7 +18,8 @@ declare module "chokidar"
|
||||
on(event: 'add', fn: (path: string, stats?: fs.Stats) => void): this;
|
||||
on(event: 'change', fn: (path: string, stats?: fs.Stats) => void): this;
|
||||
on(event: 'unlink', fn: (path: string) => void): this;
|
||||
on(event: 'raw', fn: (event: Event, path:string, details:any) => void): this;
|
||||
on(event: 'raw', fn: (event: string, path:string, details:any) => void): this;
|
||||
on(event: 'all', fn: (event: string, path: string) => void): this;
|
||||
on(event: string, fn: (path: string) => void): this;
|
||||
close(): this;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user