[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix: hash the name of the file when caching (#5654)

authored by

Vladimir and committed by
GitHub
(May 2, 2024, 10:44 AM +0200) c9e68ced f5faf423

+4 -2
+4 -2
packages/vitest/src/node/pools/rpc.ts
··· 1 + import { createHash } from 'node:crypto' 1 2 import { mkdir, writeFile } from 'node:fs/promises' 2 3 import type { RawSourceMap } from 'vite-node' 3 4 import { join } from 'pathe' ··· 30 31 const code = result.code 31 32 if (result.externalize) 32 33 return result 33 - if ('id' in result) 34 + if ('id' in result && typeof result.id === 'string') 34 35 return { id: result.id as string } 35 36 36 37 if (!code) 37 38 throw new Error(`Failed to fetch module ${id}`) 38 39 39 40 const dir = join(project.tmpDir, transformMode) 40 - const tmp = join(dir, id.replace(/[/\\?%*:|"<>]/g, '_').replace('\0', '__x00__')) 41 + const name = createHash('sha1').update(id).digest('hex') 42 + const tmp = join(dir, name) 41 43 if (promises.has(tmp)) { 42 44 await promises.get(tmp) 43 45 return { id: tmp }