A module which provides a TypeScript implementation of the Deno CLI's cache
directory logic (DENO_DIR
). This can be used in combination with other
modules to provide user loadable APIs that are like the Deno CLI's
functionality.
This also can provide user read access in Deploy to a Deno CLI's cache when the cache is checked into the repository.
import { createCache } from "@deno/cache-dir"; import { createGraph } from "@deno/graph"; // create a cache where the location will be determined environmentally const cache = createCache(); // destructuring the two functions we need to pass to the graph const { cacheInfo, load } = cache; // create a graph that will use the cache above to load and cache dependencies const graph = await createGraph("https://deno.land/x/oak@v9.0.1/mod.ts", { cacheInfo, load, }); // log out the console a similar output to `deno info` on the command line. console.log(graph.toString());
Add Package
deno add jsr:@deno/cache-dir
Import symbol
import * as cache_dir from "@deno/cache-dir";
---- OR ----
Import directly with a jsr specifier
import * as cache_dir from "jsr:@deno/cache-dir";