deno
72497f33 - feat(task): input-based caching with files/output/env (#34509)

Commit
125 days ago
feat(task): input-based caching with files/output/env (#34509) Adds input-based caching for `deno task`, addressing #26993. Tasks gain three new fields: `files` (input globs), `output` (output globs), and `env` (env var names that are part of the cache key). When a task declares `files`, Deno fingerprints the command string, appended CLI args, the values of any listed env vars, and the contents of every matching file, and skips the task on the next run if nothing changed. Tasks without `files` keep the existing always-run behavior, so caching is opt-in per task. On a cache hit, declared `output` globs are restored from the cache, so deleting an output (e.g. `dist/`) and re-running regenerates it; stale outputs from a prior run are cleared before a re-run. Each task's direct dependency fingerprints are folded into its cache key, so a downstream task re-runs when an upstream one did, and a non-cacheable dependency propagates non-cacheability downstream. The fingerprint uses SHA-256 (length-prefixed fields) so a collision can't silently skip a build, and folds in the target OS/arch and Deno version so a DENO_DIR synced across platforms or upgrades never hits across them. A mtime+size fast path lets a hit skip reading input files entirely unless a stat drifts, falling back to rehashing contents (which distinguishes a real edit from a mtime-only touch). Cache entries live under `DENO_DIR/task_cache_v1/` as a small JSON manifest; an unrecognized payload is treated as a miss, so no migration is needed. Refs #26993
Author
Parents
Loading