/** Returns the path to the user's cache directory. * * The returned value depends on the operating system and is either a string, * containing a value from the following table, or `null`. * * |Platform | Value | Example | * | ------- | ----------------------------------- | -------------------------------- | * | Linux | `$XDG_CACHE_HOME` or `$HOME`/.cache | /home/justjavac/.cache | * | macOS | `$HOME`/Library/Caches | /Users/justjavac/Library/Caches | * | Windows | `$LOCALAPPDATA` | C:\Users\justjavac\AppData\Local | */ import * as dntShim from "../../../../_dnt.shims.js"; export default function cacheDir(): string | null { switch (dntShim.Deno.build.os) { case "linux": { const xdg = dntShim.Deno.env.get("XDG_CACHE_HOME"); if (xdg) return xdg; const home = dntShim.Deno.env.get("HOME"); if (home) return `${home}/.cache`; break; } case "darwin": { const home = dntShim.Deno.env.get("HOME"); if (home) return `${home}/Library/Caches`; break; } case "windows": return dntShim.Deno.env.get("LOCALAPPDATA") ?? null; } return null; }