Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/files/node/watcher/watcherClient.ts
3296 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 { DisposableStore } from '../../../../base/common/lifecycle.js';
7
import { FileAccess } from '../../../../base/common/network.js';
8
import { getNextTickChannel, ProxyChannel } from '../../../../base/parts/ipc/common/ipc.js';
9
import { Client } from '../../../../base/parts/ipc/node/ipc.cp.js';
10
import { IFileChange } from '../../common/files.js';
11
import { AbstractUniversalWatcherClient, ILogMessage, IUniversalWatcher } from '../../common/watcher.js';
12
13
export class UniversalWatcherClient extends AbstractUniversalWatcherClient {
14
15
constructor(
16
onFileChanges: (changes: IFileChange[]) => void,
17
onLogMessage: (msg: ILogMessage) => void,
18
verboseLogging: boolean
19
) {
20
super(onFileChanges, onLogMessage, verboseLogging);
21
22
this.init();
23
}
24
25
protected override createWatcher(disposables: DisposableStore): IUniversalWatcher {
26
27
// Fork the universal file watcher and build a client around
28
// its server for passing over requests and receiving events.
29
const client = disposables.add(new Client(
30
FileAccess.asFileUri('bootstrap-fork').fsPath,
31
{
32
serverName: 'File Watcher',
33
args: ['--type=fileWatcher'],
34
env: {
35
VSCODE_ESM_ENTRYPOINT: 'vs/platform/files/node/watcher/watcherMain',
36
VSCODE_PIPE_LOGGING: 'true',
37
VSCODE_VERBOSE_LOGGING: 'true' // transmit console logs from server to client
38
}
39
}
40
));
41
42
// React on unexpected termination of the watcher process
43
disposables.add(client.onDidProcessExit(({ code, signal }) => this.onError(`terminated by itself with code ${code}, signal: ${signal} (ETERM)`)));
44
45
return ProxyChannel.toService<IUniversalWatcher>(getNextTickChannel(client.getChannel('watcher')));
46
}
47
}
48
49