Git Product home page Git Product logo

deno_cache_dir's Introduction

deno_cache_dir

jsr

Implementation of the DENO_DIR/cache for the Deno CLI.

This is designed to provide access to the cache using the same logic that the Deno CLI accesses the cache, which allows projects like deno_graph, deno_doc, dnt, and emit to access and populate the cache in the same way that the CLI does.

Permissions

Because of the nature of code, it requires several permissions to be able to work properly. If the permissions aren't granted at execution, the code will try to prompt for them, only requesting what is specifically needed to perform the task.

  • --allow-env - The code needs access to several environment variables, depending on the platform as well, these can include HOME, USERPROFILE, LOCALAPPDATA, XDG_CACHE_HOME, DENO_DIR, and DENO_AUTH_TOKENS.
  • --allow-read - In certain cases the code needs to determine the current working directory, as well as read the cache files, so it requires read permission.
  • --allow-write - The code requires write permission to the root of the cache directory.
  • --allow-net - The code requires net access to any remote modules that are not found in the cache.

This can just be granted on startup to avoid being prompted for them.

Example

> deno add @deno/cache-dir
> deno add @deno/graph

Using the cache and the file fetcher to provide modules to build a module graph:

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 load we need to pass to the graph
const { load } = cache;
// create a graph that will use the cache above to load and cache dependencies
const graph = await createGraph("https://deno.land/x/[email protected]/mod.ts", {
  load,
});

// log out the console a similar output to `deno info` on the command line.
console.log(graph.toString());

deno_cache_dir's People

Contributors

dsherret avatar denobot avatar kitsonk avatar littledivy avatar crowlkats avatar jollytoad avatar nberlette avatar valpackett avatar mimbrown avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.