Skip to content

Commit

Permalink
refactor: remove VitestCache.clearCache method (#5602)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Apr 24, 2024
1 parent 23f29ce commit f1bec62
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 93 deletions.
35 changes: 0 additions & 35 deletions packages/vitest/src/node/cache/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import fs from 'node:fs'
import crypto from 'node:crypto'
import { findUp } from 'find-up'
import { resolve } from 'pathe'
import { loadConfigFromFile } from 'vite'
import { configFiles } from '../../constants'
import type { CliOptions } from '../cli/cli-api'
import { slash } from '../../utils'
import { FilesStatsCache } from './files'
import { ResultsCache } from './results'
Expand All @@ -27,34 +22,4 @@ export class VitestCache {
? resolve(root, baseDir, crypto.createHash('md5').update(projectName, 'utf-8').digest('hex'))
: resolve(root, baseDir)
}

static async clearCache(options: CliOptions) {
const root = resolve(options.root || process.cwd())

const configPath = options.config === false
? false
: options.config
? resolve(root, options.config)
: await findUp(configFiles, { cwd: root } as any)

const config = configPath
? (await loadConfigFromFile({ command: 'serve', mode: 'test' }, configPath))?.config
: undefined

const cache = config?.test?.cache
const projectName = config?.test?.name

if (cache === false)
throw new Error('Cache is disabled')

const cachePath = VitestCache.resolveCacheDir(root, cache?.dir, projectName)

let cleared = false

if (fs.existsSync(cachePath)) {
fs.rmSync(cachePath, { recursive: true, force: true })
cleared = true
}
return { dir: cachePath, cleared }
}
}
1 change: 0 additions & 1 deletion test/cache/.gitignore

This file was deleted.

12 changes: 0 additions & 12 deletions test/cache/package.json

This file was deleted.

26 changes: 0 additions & 26 deletions test/cache/test/clear-cache.test.ts

This file was deleted.

9 changes: 0 additions & 9 deletions test/cache/vitest-custom.config.ts

This file was deleted.

10 changes: 0 additions & 10 deletions test/cache/vitest.config.ts

This file was deleted.

0 comments on commit f1bec62

Please sign in to comment.