-
Notifications
You must be signed in to change notification settings - Fork 29.7k
/
parcelWatcherService.ts
51 lines (41 loc) · 1.98 KB
/
parcelWatcherService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
import { IDiskFileChange, ILogMessage, IWatcherService, IWatchRequest, WatcherService } from 'vs/platform/files/common/watcher';
import { ISharedProcessWorkerWorkbenchService } from 'vs/workbench/services/sharedProcess/electron-sandbox/sharedProcessWorkerWorkbenchService';
export class ParcelFileWatcher extends WatcherService {
private readonly service: IWatcherService;
constructor(
requests: IWatchRequest[],
private readonly onDidFilesChange: (changes: IDiskFileChange[]) => void,
private readonly onLogMessage: (msg: ILogMessage) => void,
verboseLogging: boolean,
private readonly sharedProcessWorkerWorkbenchService: ISharedProcessWorkerWorkbenchService
) {
super();
// Start watching
{
// Acquire parcel watcher via shared process worker
const watcherChannel = this.sharedProcessWorkerWorkbenchService.createWorkerChannel({
moduleId: 'vs/platform/files/node/watcher/parcel/watcherApp',
type: 'watcherServiceParcelSharedProcess'
}, 'watcher').channel;
// Initialize watcher
this.service = ProxyChannel.toService<IWatcherService>(watcherChannel);
this.service.setVerboseLogging(verboseLogging);
// Wire in event handlers
this._register(this.service.onDidChangeFile(e => this.onDidFilesChange(e)));
this._register(this.service.onDidLogMessage(e => this.onLogMessage(e)));
// Start watching
this.watch(requests);
}
}
setVerboseLogging(verboseLogging: boolean): Promise<void> {
return this.service.setVerboseLogging(verboseLogging);
}
watch(requests: IWatchRequest[]): Promise<void> {
return this.service.watch(requests);
}
}