diff --git a/docs/05-command-line.md b/docs/05-command-line.md index a8e8cc413..bd002f0fd 100644 --- a/docs/05-command-line.md +++ b/docs/05-command-line.md @@ -218,7 +218,7 @@ When running a file with and without line numbers, line numbers take precedence. ## Resetting AVA's cache -AVA may cache certain files, especially when you use our [`@ava/babel`](https://github.com/avajs/babel) provider. If it seems like your latest changes aren't being picked up by AVA you can reset the cache by running: +AVA itself does not cache files unless used with our [`@ava/babel`](https://github.com/avajs/babel) provider. If it seems like your latest changes aren't being picked up by AVA you can try resetting the cache by running: ```console npx ava reset-cache diff --git a/docs/06-configuration.md b/docs/06-configuration.md index 63f20aed6..dce63e608 100644 --- a/docs/06-configuration.md +++ b/docs/06-configuration.md @@ -45,7 +45,7 @@ Arguments passed to the CLI will always take precedence over the CLI options con - `files`: an array of glob patterns to select test files. Files with an underscore prefix are ignored. By default only selects files with `cjs`, `mjs` & `js` extensions, even if the pattern matches other files. Specify `extensions` to allow other file extensions - `ignoredByWatcher`: an array of glob patterns to match files that, even if changed, are ignored by the watcher. See the [watch mode recipe for details](https://github.com/avajs/ava/blob/main/docs/recipes/watch-mode.md) - `match`: not typically useful in the `package.json` configuration, but equivalent to [specifying `--match` on the CLI](./05-command-line.md#running-tests-with-matching-titles) -- `cache`: cache compiled files under `node_modules/.cache/ava`. If `false`, files are cached in a temporary directory instead +- `cache`: defaults to `true` to cache compiled files under `node_modules/.cache/ava`. If `false`, files are cached in a temporary directory instead - `concurrency`: max number of test files running at the same time (default: CPU cores) - `workerThreads`: use worker threads to run tests (requires AVA 4, enabled by default). If `false`, tests will run in child processes (how AVA 3 behaves) - `failFast`: stop running further tests once a test fails diff --git a/lib/cli.js b/lib/cli.js index 2985b1f49..39983822e 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -244,18 +244,20 @@ export default async () => { // eslint-disable-line complexity const {nonSemVerExperiments: experiments, projectDir} = conf; if (resetCache) { const cacheDir = path.join(projectDir, 'node_modules', '.cache', 'ava'); + try { - await del('*', { - cwd: cacheDir, - nodir: true - }); - console.error(`\n${chalk.green(figures.tick)} Removed AVA cache files in ${cacheDir}`); + const deletedFilePaths = await del('*', {cwd: cacheDir}); + + if (deletedFilePaths.length === 0) { + console.log(`\n${chalk.green(figures.tick)} No cache files to remove`); + } else { + console.log(`\n${chalk.green(figures.tick)} Removed AVA cache files in ${cacheDir}`); + } + process.exit(0); // eslint-disable-line unicorn/no-process-exit } catch (error) { exit(`Error removing AVA cache files in ${cacheDir}\n\n${chalk.gray((error && error.stack) || error)}`); } - - return; } if (argv.watch) {