From e8311bb74d2256f000e8147b0738d4a27b9bb3be Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Mon, 19 Feb 2024 17:06:42 +0100 Subject: [PATCH] chore: cleanup --- src/extension.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 662797bf..29dd3f1e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -31,29 +31,27 @@ import { openTestTag } from './tags' import { workerPath } from './constants' export async function activate(context: vscode.ExtensionContext) { - // TODO: just to test, improve the logic! - const workspacePath = vscode.workspace.workspaceFolders?.[0].uri.fsPath - log.info('workspace path', workspacePath, workerPath) - if (workspacePath) { - const vitestPath = require.resolve('vitest', { paths: [workspacePath] }) // resolves to cjs + const workspacePaths = vscode.workspace.workspaceFolders?.map(x => x.uri.fsPath) + if (workspacePaths?.length) { + const vitestPath = require.resolve('vitest', { paths: workspacePaths }) // resolves to cjs log.info('vitest path', vitestPath, resolve(dirname(vitestPath), './dist/node.js')) const worker = new Worker(workerPath, { workerData: { - root: workspacePath, + root: workspacePaths[0], vitestPath: resolve(dirname(vitestPath), './dist/node.js'), }, }) worker.stdout.on('data', (d) => { - log.info('worker error', d.toString()) + log.info('worker log', d.toString()) }) worker.stderr.on('data', (d) => { log.error('worker error', d.toString()) }) worker.on('message', (d) => { log.info(JSON.stringify(d)) - // worker.terminate() }) } + await detectVitestEnvironmentFolders() if (vitestEnvironmentFolders.length === 0) { log.info('The extension is not activated because no Vitest environment was detected.')