Skip to content

Commit 3dd2927

Browse files
committed
chore: explain why you see a message
1 parent 904d36a commit 3dd2927

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/api/pkg.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,20 @@ function resolveVitestConfig(showWarning: boolean, configOrWorkspaceFile: vscode
4949
if (!vitest) {
5050
if (showWarning) {
5151
const isVitestConfig = configOrWorkspaceFile.fsPath.includes('vitest.')
52-
if (isVitestConfig || isVitestInPackageJson(folder.uri.fsPath))
53-
vscode.window.showWarningMessage(`Vitest not found in "${basename(dirname(configOrWorkspaceFile.fsPath))}" folder. Please run \`npm i --save-dev vitest\` to install Vitest.`)
52+
const isInPkgJson = isVitestInPackageJson(folder.uri.fsPath)
53+
if (isVitestConfig || isInPkgJson) {
54+
const message = [
55+
`Vitest not found in "${basename(dirname(configOrWorkspaceFile.fsPath))}" folder. `,
56+
`Please run \`npm i --save-dev vitest\` to install Vitest. `,
57+
]
58+
if (isVitestConfig) {
59+
message.push('You are seeing this message because the extension found a Vitest config in this folder.')
60+
}
61+
else if (isInPkgJson) {
62+
message.push('You are seeing this message because the extension found a "vitest" dependency in the `package.json` file.')
63+
}
64+
vscode.window.showWarningMessage(message.join(''))
65+
}
5466
}
5567
log.error('[API]', `Vitest not found for ${configOrWorkspaceFile}.`)
5668
return null

0 commit comments

Comments
 (0)