1
1
import { existsSync , promises as fs } from 'node:fs'
2
2
import type { Writable } from 'node:stream'
3
3
import type { ViteDevServer } from 'vite'
4
- import { dirname , join , normalize , relative , resolve } from 'pathe'
4
+ import { dirname , join , normalize , relative } from 'pathe'
5
5
import mm from 'micromatch'
6
6
import { ViteNodeRunner } from 'vite-node/client'
7
7
import { SnapshotManager } from '@vitest/snapshot/manager'
@@ -12,10 +12,10 @@ import { version } from '../../package.json' with { type: 'json' }
12
12
import { getTasks , hasFailed , noop , slash , toArray , wildcardPatternToRegExp } from '../utils'
13
13
import { getCoverageProvider } from '../integrations/coverage'
14
14
import { workspacesFiles as workspaceFiles } from '../constants'
15
- import { rootDir } from '../paths'
16
15
import { WebSocketReporter } from '../api/setup'
17
16
import type { SerializedCoverageConfig } from '../runtime/config'
18
17
import type { ArgumentsType , OnServerRestartHandler , ProvidedContext , UserConsoleLog } from '../types/general'
18
+ import { distDir } from '../paths'
19
19
import type { ProcessPool , WorkspaceSpec } from './pool'
20
20
import { createPool , getFilePoolName } from './pool'
21
21
import { createBenchmarkReporters , createReporters } from './reporters/utils'
@@ -78,7 +78,7 @@ export class Vitest {
78
78
private resolvedProjects : WorkspaceProject [ ] = [ ]
79
79
public projects : WorkspaceProject [ ] = [ ]
80
80
81
- public distPath ! : string
81
+ public distPath = distDir
82
82
83
83
private _cachedSpecs = new Map < string , WorkspaceSpec [ ] > ( )
84
84
@@ -106,7 +106,6 @@ export class Vitest {
106
106
this . pool = undefined
107
107
this . coverageProvider = undefined
108
108
this . runningPromise = undefined
109
- this . distPath = undefined !
110
109
this . _cachedSpecs . clear ( )
111
110
112
111
const resolved = resolveConfig ( this . mode , options , server . config , this . logger )
@@ -560,20 +559,7 @@ export class Vitest {
560
559
}
561
560
}
562
561
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
-
574
562
async runFiles ( specs : TestSpecification [ ] , allTestsRun : boolean ) {
575
- await this . initializeDistPath ( )
576
-
577
563
const filepaths = specs . map ( spec => spec . moduleId )
578
564
this . state . collectPaths ( filepaths )
579
565
@@ -638,8 +624,6 @@ export class Vitest {
638
624
}
639
625
640
626
async collectFiles ( specs : WorkspaceSpec [ ] ) {
641
- await this . initializeDistPath ( )
642
-
643
627
const filepaths = specs . map ( spec => spec . moduleId )
644
628
this . state . collectPaths ( filepaths )
645
629
0 commit comments