@@ -8,6 +8,7 @@ const _require = require
88export interface VitestResolution {
99 vitestPackageJsonPath : string
1010 vitestNodePath : string
11+ packageName : string
1112 pnp ?: {
1213 loaderPath : string
1314 pnpPath : string
@@ -23,31 +24,40 @@ export function resolveVitestPackage(
2324 return {
2425 vitestNodePath : resolveVitestNodePath ( vitestPackageJsonPath ) ,
2526 vitestPackageJsonPath,
27+ packageName : 'Vitest' ,
2628 }
2729 }
2830 const vitePlus = resolveVitePlusPackagePath ( cwd )
2931 if ( vitePlus ) {
3032 return {
3133 vitestNodePath : resolveViePlusVitestNodePath ( vitePlus ) ,
3234 vitestPackageJsonPath : vitePlus ,
35+ packageName : 'VitePlus' ,
3336 }
3437 }
3538
3639 const pnpCwd = folder ?. uri . fsPath || cwd
3740 const pnp = resolvePnp ( pnpCwd )
3841 if ( ! pnp ) return null
39- const vitestNodePath =
40- resolvePnpPackagePath ( pnp . pnpApi , 'vitest/node' , pnpCwd ) ||
41- resolvePnpPackagePath ( pnp . pnpApi , 'vite-plus/test/node' , pnpCwd )
42- if ( ! vitestNodePath ) return null
43- return {
44- vitestNodePath,
45- vitestPackageJsonPath : '' , // we don't read pkg.json for pnp
46- pnp : {
47- loaderPath : pnp . pnpLoader ,
48- pnpPath : pnp . pnpPath ,
49- } ,
42+ const vitestNodePath = resolvePnpPackagePath ( pnp . pnpApi , 'vitest/node' , pnpCwd )
43+ if ( vitestNodePath ) {
44+ return {
45+ vitestNodePath,
46+ vitestPackageJsonPath : '' , // we don't read pkg.json for pnp
47+ pnp,
48+ packageName : 'Vitest' ,
49+ }
50+ }
51+ const vitePlusNodePath = resolvePnpPackagePath ( pnp . pnpApi , 'vite-plus/test/node' , pnpCwd )
52+ if ( vitePlusNodePath ) {
53+ return {
54+ vitestNodePath : vitePlusNodePath ,
55+ vitestPackageJsonPath : '' , // we don't read pkg.json for pnp
56+ pnp,
57+ packageName : 'VitePlus' ,
58+ }
5059 }
60+ return null
5161}
5262
5363export function resolveVitestPackagePath ( cwd : string , folder : vscode . WorkspaceFolder | undefined ) {
@@ -91,7 +101,7 @@ export function resolvePnp(cwd: string) {
91101 }
92102 const pnpApi = _require ( pnpPath )
93103 return {
94- pnpLoader : require . resolve ( './.pnp.loader.mjs' , {
104+ loaderPath : require . resolve ( './.pnp.loader.mjs' , {
95105 paths : [ dirname ( pnpPath ) ] ,
96106 } ) ,
97107 pnpPath,
0 commit comments