Path: blob/main/src/vs/platform/files/node/watcher/watcherClient.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { DisposableStore } from '../../../../base/common/lifecycle.js';6import { FileAccess } from '../../../../base/common/network.js';7import { getNextTickChannel, ProxyChannel } from '../../../../base/parts/ipc/common/ipc.js';8import { Client } from '../../../../base/parts/ipc/node/ipc.cp.js';9import { IFileChange } from '../../common/files.js';10import { AbstractUniversalWatcherClient, ILogMessage, IUniversalWatcher } from '../../common/watcher.js';1112export class UniversalWatcherClient extends AbstractUniversalWatcherClient {1314constructor(15onFileChanges: (changes: IFileChange[]) => void,16onLogMessage: (msg: ILogMessage) => void,17verboseLogging: boolean18) {19super(onFileChanges, onLogMessage, verboseLogging);2021this.init();22}2324protected override createWatcher(disposables: DisposableStore): IUniversalWatcher {2526// Fork the universal file watcher and build a client around27// its server for passing over requests and receiving events.28const client = disposables.add(new Client(29FileAccess.asFileUri('bootstrap-fork').fsPath,30{31serverName: 'File Watcher',32args: ['--type=fileWatcher'],33env: {34VSCODE_ESM_ENTRYPOINT: 'vs/platform/files/node/watcher/watcherMain',35VSCODE_PIPE_LOGGING: 'true',36VSCODE_VERBOSE_LOGGING: 'true' // transmit console logs from server to client37}38}39));4041// React on unexpected termination of the watcher process42disposables.add(client.onDidProcessExit(({ code, signal }) => this.onError(`terminated by itself with code ${code}, signal: ${signal} (ETERM)`)));4344return ProxyChannel.toService<IUniversalWatcher>(getNextTickChannel(client.getChannel('watcher')));45}46}474849