22 * Tool Download + Cache Engine
33 *
44 * Downloads pinned tool versions, verifies checksums, and caches them
5- * in a user-level directory shared across repos .
5+ * in the repo-local .cache/external-tools/ directory (gitignored via .cache/) .
66 *
7- * Cache location:
8- * - Linux: $XDG_CACHE_HOME/.external-tools-cache/ or ~/.cache/.external-tools-cache/
9- * - macOS: ~/.cache/.external-tools-cache/
10- * - Windows: %LOCALAPPDATA%/.external-tools-cache/
11- * - Override: $EXTERNAL_TOOLS_CACHE
7+ * Override: $EXTERNAL_TOOLS_CACHE
128 */
139
1410import { createHash } from 'node:crypto'
1511import { createReadStream , existsSync , readFileSync } from 'node:fs'
1612import { promises as fs } from 'node:fs'
17- import os from 'node:os'
1813import path from 'node:path'
1914import process from 'node:process'
2015
@@ -24,23 +19,14 @@ import { spawn } from '@socketsecurity/lib/spawn'
2419const logger = getDefaultLogger ( )
2520
2621/**
27- * Get the user-level cache directory for downloaded tools.
22+ * Get the repo-local cache directory for downloaded tools.
2823 * @returns {string }
2924 */
3025export function getCacheDir ( ) {
31- // Allow override via environment variable
3226 if ( process . env . EXTERNAL_TOOLS_CACHE ) {
3327 return process . env . EXTERNAL_TOOLS_CACHE
3428 }
35-
36- if ( process . platform === 'win32' ) {
37- const localAppData = process . env . LOCALAPPDATA || path . join ( os . homedir ( ) , 'AppData' , 'Local' )
38- return path . join ( localAppData , '.external-tools-cache' )
39- }
40-
41- // Unix: XDG_CACHE_HOME or ~/.cache
42- const xdgCache = process . env . XDG_CACHE_HOME || path . join ( os . homedir ( ) , '.cache' )
43- return path . join ( xdgCache , '.external-tools-cache' )
29+ return path . join ( process . cwd ( ) , '.cache' , 'external-tools' )
4430}
4531
4632/**
0 commit comments