mirror of
https://github.com/Microsoft/vscode
synced 2024-09-18 01:58:27 +00:00
streamline APIs of chockidar and nsfw
This commit is contained in:
parent
c706d49539
commit
1faa060037
|
@ -215,6 +215,21 @@ export class NsfwWatcherService implements IWatcherService {
|
|||
return TPromise.join(promises).then(() => void 0);
|
||||
}
|
||||
|
||||
public setVerboseLogging(enabled: boolean): TPromise<void> {
|
||||
this._verboseLogging = enabled;
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
public stop(): TPromise<void> {
|
||||
for (let path in this._pathWatchers) {
|
||||
let watcher = this._pathWatchers[path];
|
||||
watcher.ready.then(watcher => watcher.stop());
|
||||
delete this._pathWatchers[path];
|
||||
}
|
||||
this._pathWatchers = Object.create(null);
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a set of root paths by removing any root paths that are
|
||||
* sub-paths of other roots.
|
||||
|
|
|
@ -25,4 +25,6 @@ export interface IWatchError {
|
|||
export interface IWatcherService {
|
||||
watch(options: IWatcherOptions): Event<IRawFileChange[] | IWatchError>;
|
||||
setRoots(roots: IWatcherRequest[]): TPromise<void>;
|
||||
setVerboseLogging(enabled: boolean): TPromise<void>;
|
||||
stop(): TPromise<void>;
|
||||
}
|
|
@ -16,6 +16,8 @@ export interface IWatcherChannel extends IChannel {
|
|||
listen<T>(event: string, arg?: any): Event<T>;
|
||||
|
||||
call(command: 'setRoots', request: IWatcherRequest[]): TPromise<void>;
|
||||
call(command: 'setVerboseLogging', enable: boolean): TPromise<void>;
|
||||
call(command: 'stop'): TPromise<void>;
|
||||
call<T>(command: string, arg?: any): TPromise<T>;
|
||||
}
|
||||
|
||||
|
@ -30,9 +32,11 @@ export class WatcherChannel implements IWatcherChannel {
|
|||
throw new Error('No events');
|
||||
}
|
||||
|
||||
call(command: string, arg: any): TPromise<any> {
|
||||
call(command: string, arg?: any): TPromise<any> {
|
||||
switch (command) {
|
||||
case 'setRoots': return this.service.setRoots(arg);
|
||||
case 'setVerboseLogging': return this.service.setVerboseLogging(arg);
|
||||
case 'stop': return this.service.stop();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
@ -46,7 +50,15 @@ export class WatcherChannelClient implements IWatcherService {
|
|||
return this.channel.listen('watch', options);
|
||||
}
|
||||
|
||||
setVerboseLogging(enable: boolean): TPromise<void> {
|
||||
return this.channel.call('setVerboseLogging', enable);
|
||||
}
|
||||
|
||||
setRoots(roots: IWatcherRequest[]): TPromise<void> {
|
||||
return this.channel.call('setRoots', roots);
|
||||
}
|
||||
|
||||
stop(): TPromise<void> {
|
||||
return this.channel.call('stop');
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue