Skip to content

Commit

Permalink
chore(server): fix connection when not testing
Browse files Browse the repository at this point in the history
Aurelia did not show up in output
  • Loading branch information
hiaux0 committed Dec 26, 2022
1 parent 0a3dbea commit 5464ecc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
22 changes: 19 additions & 3 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 10 additions & 2 deletions tests/common/mock-server/mock-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit 5464ecc

Please sign in to comment.