Skip to content

Commit ddda6ed

Browse files
authored
Clarify caching
1 parent a87460a commit ddda6ed

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

docs/05-command-line.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ When running a file with and without line numbers, line numbers take precedence.
218218

219219
## Resetting AVA's cache
220220

221-
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:
221+
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:
222222

223223
```console
224224
npx ava reset-cache

docs/06-configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Arguments passed to the CLI will always take precedence over the CLI options con
4545
- `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
4646
- `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)
4747
- `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)
48-
- `cache`: cache compiled files under `node_modules/.cache/ava`. If `false`, files are cached in a temporary directory instead
48+
- `cache`: defaults to `true` to cache compiled files under `node_modules/.cache/ava`. If `false`, files are cached in a temporary directory instead
4949
- `concurrency`: max number of test files running at the same time (default: CPU cores)
5050
- `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)
5151
- `failFast`: stop running further tests once a test fails

lib/cli.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,20 @@ export default async () => { // eslint-disable-line complexity
244244
const {nonSemVerExperiments: experiments, projectDir} = conf;
245245
if (resetCache) {
246246
const cacheDir = path.join(projectDir, 'node_modules', '.cache', 'ava');
247+
247248
try {
248-
await del('*', {
249-
cwd: cacheDir,
250-
nodir: true
251-
});
252-
console.error(`\n${chalk.green(figures.tick)} Removed AVA cache files in ${cacheDir}`);
249+
const deletedFilePaths = await del('*', {cwd: cacheDir});
250+
251+
if (deletedFilePaths.length === 0) {
252+
console.log(`\n${chalk.green(figures.tick)} No cache files to remove`);
253+
} else {
254+
console.log(`\n${chalk.green(figures.tick)} Removed AVA cache files in ${cacheDir}`);
255+
}
256+
253257
process.exit(0); // eslint-disable-line unicorn/no-process-exit
254258
} catch (error) {
255259
exit(`Error removing AVA cache files in ${cacheDir}\n\n${chalk.gray((error && error.stack) || error)}`);
256260
}
257-
258-
return;
259261
}
260262

261263
if (argv.watch) {

0 commit comments

Comments
 (0)