11import { existsSync , promises as fs } from 'node:fs'
22import type { Writable } from 'node:stream'
33import type { ViteDevServer } from 'vite'
4- import { dirname , join , normalize , relative , resolve } from 'pathe'
4+ import { dirname , join , normalize , relative } from 'pathe'
55import mm from 'micromatch'
66import { ViteNodeRunner } from 'vite-node/client'
77import { SnapshotManager } from '@vitest/snapshot/manager'
@@ -12,10 +12,10 @@ import { version } from '../../package.json' with { type: 'json' }
1212import { getTasks , hasFailed , noop , slash , toArray , wildcardPatternToRegExp } from '../utils'
1313import { getCoverageProvider } from '../integrations/coverage'
1414import { workspacesFiles as workspaceFiles } from '../constants'
15- import { rootDir } from '../paths'
1615import { WebSocketReporter } from '../api/setup'
1716import type { SerializedCoverageConfig } from '../runtime/config'
1817import type { ArgumentsType , OnServerRestartHandler , ProvidedContext , UserConsoleLog } from '../types/general'
18+ import { distDir } from '../paths'
1919import type { ProcessPool , WorkspaceSpec } from './pool'
2020import { createPool , getFilePoolName } from './pool'
2121import { createBenchmarkReporters , createReporters } from './reporters/utils'
@@ -78,7 +78,7 @@ export class Vitest {
7878 private resolvedProjects : WorkspaceProject [ ] = [ ]
7979 public projects : WorkspaceProject [ ] = [ ]
8080
81- public distPath ! : string
81+ public distPath = distDir
8282
8383 private _cachedSpecs = new Map < string , WorkspaceSpec [ ] > ( )
8484
@@ -106,7 +106,6 @@ export class Vitest {
106106 this . pool = undefined
107107 this . coverageProvider = undefined
108108 this . runningPromise = undefined
109- this . distPath = undefined !
110109 this . _cachedSpecs . clear ( )
111110
112111 const resolved = resolveConfig ( this . mode , options , server . config , this . logger )
@@ -560,20 +559,7 @@ export class Vitest {
560559 }
561560 }
562561
563- private async initializeDistPath ( ) {
564- if ( this . distPath ) {
565- return
566- }
567-
568- // if Vitest is running globally, then we should still import local vitest if possible
569- const projectVitestPath = await this . vitenode . resolveId ( 'vitest' )
570- const vitestDir = projectVitestPath ? resolve ( projectVitestPath . id , '../..' ) : rootDir
571- this . distPath = join ( vitestDir , 'dist' )
572- }
573-
574562 async runFiles ( specs : TestSpecification [ ] , allTestsRun : boolean ) {
575- await this . initializeDistPath ( )
576-
577563 const filepaths = specs . map ( spec => spec . moduleId )
578564 this . state . collectPaths ( filepaths )
579565
@@ -638,8 +624,6 @@ export class Vitest {
638624 }
639625
640626 async collectFiles ( specs : WorkspaceSpec [ ] ) {
641- await this . initializeDistPath ( )
642-
643627 const filepaths = specs . map ( spec => spec . moduleId )
644628 this . state . collectPaths ( filepaths )
645629
0 commit comments