mirror of
https://github.com/Microsoft/vscode
synced 2024-09-06 01:41:29 +00:00
![Benjamin Pasero](/assets/img/avatar_default.png)
* git - adopt new out of workspace watching support (#140691) * dispose emitter too * 💄 Co-authored-by: Joao Moreno <joao.moreno@microsoft.com>
23 lines
869 B
TypeScript
23 lines
869 B
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { Event, RelativePattern, Uri, workspace } from 'vscode';
|
|
import { IDisposable, anyEvent } from './util';
|
|
|
|
export interface IFileWatcher extends IDisposable {
|
|
readonly event: Event<Uri>;
|
|
}
|
|
|
|
export function watch(location: string): IFileWatcher {
|
|
const watcher = workspace.createFileSystemWatcher(new RelativePattern(location, '*'));
|
|
|
|
return new class implements IFileWatcher {
|
|
event = anyEvent(watcher.onDidCreate, watcher.onDidChange, watcher.onDidDelete);
|
|
dispose() {
|
|
watcher.dispose();
|
|
}
|
|
};
|
|
}
|