Skip to content

Commit f1bec62

Browse files
authored
refactor: remove VitestCache.clearCache method (#5602)
1 parent 23f29ce commit f1bec62

File tree

6 files changed

+0
-93
lines changed

6 files changed

+0
-93
lines changed
Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import fs from 'node:fs'
21
import crypto from 'node:crypto'
3-
import { findUp } from 'find-up'
42
import { resolve } from 'pathe'
5-
import { loadConfigFromFile } from 'vite'
6-
import { configFiles } from '../../constants'
7-
import type { CliOptions } from '../cli/cli-api'
83
import { slash } from '../../utils'
94
import { FilesStatsCache } from './files'
105
import { ResultsCache } from './results'
@@ -27,34 +22,4 @@ export class VitestCache {
2722
? resolve(root, baseDir, crypto.createHash('md5').update(projectName, 'utf-8').digest('hex'))
2823
: resolve(root, baseDir)
2924
}
30-
31-
static async clearCache(options: CliOptions) {
32-
const root = resolve(options.root || process.cwd())
33-
34-
const configPath = options.config === false
35-
? false
36-
: options.config
37-
? resolve(root, options.config)
38-
: await findUp(configFiles, { cwd: root } as any)
39-
40-
const config = configPath
41-
? (await loadConfigFromFile({ command: 'serve', mode: 'test' }, configPath))?.config
42-
: undefined
43-
44-
const cache = config?.test?.cache
45-
const projectName = config?.test?.name
46-
47-
if (cache === false)
48-
throw new Error('Cache is disabled')
49-
50-
const cachePath = VitestCache.resolveCacheDir(root, cache?.dir, projectName)
51-
52-
let cleared = false
53-
54-
if (fs.existsSync(cachePath)) {
55-
fs.rmSync(cachePath, { recursive: true, force: true })
56-
cleared = true
57-
}
58-
return { dir: cachePath, cleared }
59-
}
6025
}

test/cache/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/cache/package.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

test/cache/test/clear-cache.test.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/cache/vitest-custom.config.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/cache/vitest.config.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)