Skip to content

Commit

Permalink
chore: normalize module path in outside of module error helper
Browse files Browse the repository at this point in the history
So it will look right on windows
  • Loading branch information
sheremet-va committed May 5, 2022
1 parent 55d380c commit 8d2dd75
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/vitest/src/node/error.ts
@@ -1,7 +1,7 @@
/* eslint-disable prefer-template */
/* eslint-disable no-template-curly-in-string */
import { existsSync, readFileSync } from 'fs'
import { join, relative } from 'pathe'
import { join, normalize, relative } from 'pathe'
import c from 'picocolors'
import cliTruncate from 'cli-truncate'
import type { ErrorWithDiff, ParsedStack, Position } from '../types'
Expand Down Expand Up @@ -108,7 +108,7 @@ function handleImportOutsideModuleError(stack: string, ctx: Vitest) {
if (!esmErrors.some(e => stack.includes(e)))
return

const path = stack.split('\n')[0].trim()
const path = normalize(stack.split('\n')[0].trim())
let name = path.split('/node_modules/').pop() || ''
if (name?.startsWith('@'))
name = name.split('/').slice(0, 2).join('/')
Expand Down

0 comments on commit 8d2dd75

Please sign in to comment.