Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/git/src/watch.ts
3314 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Event, RelativePattern, Uri, workspace } from 'vscode';
7
import { IDisposable, anyEvent } from './util';
8
9
export interface IFileWatcher extends IDisposable {
10
readonly event: Event<Uri>;
11
}
12
13
export function watch(location: string): IFileWatcher {
14
const watcher = workspace.createFileSystemWatcher(new RelativePattern(location, '*'));
15
16
return new class implements IFileWatcher {
17
event = anyEvent(watcher.onDidCreate, watcher.onDidChange, watcher.onDidDelete);
18
dispose() {
19
watcher.dispose();
20
}
21
};
22
}
23
24