From 5464eccfb9caa697f778d3877d12d6d27dddc4d0 Mon Sep 17 00:00:00 2001 From: hdn Date: Mon, 26 Dec 2022 01:07:58 +0100 Subject: [PATCH] chore(server): fix connection when not testing Aurelia did not show up in output --- server/src/server.ts | 22 +++++++++++++++++++--- tests/common/mock-server/mock-server.ts | 12 ++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/server/src/server.ts b/server/src/server.ts index 29c2053b..2fec3347 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -39,10 +39,22 @@ import { globalContainer } from './core/container'; import { initDependencyInjection } from './core/depdencenyInjection'; const logger = new Logger('Server'); +const isTest = process.env.NODE_ENV; // Create a connection for the server. The connection uses Node's IPC as a transport. // Also include all preview / proposed LSP features. -export const connection = createConnection(ProposedFeatures.all, process.stdin, process.stdout); +let processStdIn; +let processStdOut; +if (isTest) { + processStdIn = process.stdin; + processStdOut = process.stdout; +} +export const connection = createConnection( + ProposedFeatures.all, + // @ts-ignore + processStdIn, + processStdOut +); // Create a simple text document manager. The text document manager // supports full document sync only @@ -347,8 +359,12 @@ async function initAurelia(forceReinit?: boolean) { rootDirectory, }; - - initDependencyInjection(globalContainer, connection, extensionSettings, documents); + initDependencyInjection( + globalContainer, + connection, + extensionSettings, + documents + ); aureliaServer = new AureliaServer( globalContainer, connection, diff --git a/tests/common/mock-server/mock-server.ts b/tests/common/mock-server/mock-server.ts index 6c0d5e10..23252c0e 100644 --- a/tests/common/mock-server/mock-server.ts +++ b/tests/common/mock-server/mock-server.ts @@ -28,6 +28,7 @@ const monorepoFixtureDir = path.resolve( 'tests/testFixture/src/monorepo' ); const rootDirectory = `file:/${monorepoFixtureDir}`; +const isTest = process.env.NODE_ENV; export class MockServer { public textDocuments: MockTextDocuments; @@ -44,10 +45,17 @@ export class MockServer { private readonly activeDocuments: TextDocument[] = [] ) { this.textDocuments = new MockTextDocuments(this.workspaceRootUri); + let processStdIn; + let processStdOut; + if (isTest) { + processStdIn = process.stdin; + processStdOut = process.stdout; + } const mockConnection = createConnection( ProposedFeatures.all, - process.stdin, - process.stdout + // @ts-ignore + processStdIn, + processStdOut ); this.aureliaServer = new AureliaServer( this.container,