-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: add complete docs for all dotenv functionality #3560
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! LGTM
import { load } from "https://deno.land/std@0.199.0/dotenv/mod.ts";
await load(); import { load } from "https://deno.land/std@0.199.0/dotenv/mod.ts";
await load({ restrictEnvAccessTo: ["FOO", "BAR"] }); |
Thanks @kt3k . I see the differences in the permission prompts, but not any functional differences in running it. For example, running this code: import { load } from "https://deno.land/std@0.199.0/dotenv/mod.ts";
const conf = await load({ restrictEnvAccessTo: ["FOO", "BAR"] });
console.log(conf);
console.log(Deno.env.get("FOO"));
console.log(Deno.env.get("BAR"));
console.log(Deno.env.get("HELLO")); with this command: HELLO=world FOO=this BAR=that deno run --allow-read main.ts prompts me first for FOO and BAR then processes the first 3 console outputs, then prompts for HELLO then outputs the last console output. However, conf is empty, so other than prompting for individual env variables permissions vs all env variables, I can't see any reason why you'd use this? Nothing is actually restricted here, e.g. I can still access HELLO. |
Then compare the below 2 scripts: import { load } from "https://deno.land/std@0.199.0/dotenv/mod.ts";
console.log(await load()); import { load } from "https://deno.land/std@0.199.0/dotenv/mod.ts";
const conf = await load({ restrictEnvAccessTo: ["FOO", "BAR"] }); With
With the command The first one should print |
@kt3k Ah! I see, it restricts access to expansion in the .env file from process supplied env variables. I understand now how it works, thanks for the follow up. Still puzzled however on the use case. If you want to use the conf rather than |
The main point of The original issue: #2534 |
I now feel the way we read env vars in I created an issue #3572 |
While looking at #3492 it was clear that the documentation for dotenv module was incomplete. This PR attempts to address this by including all options, capabilities and files associated with the dotenv module.
Note, for
restrictEnvAccessTo
, I was very unclear as to the purpose of this. No matter what I tried, this option did nothing. Either this is a bug or I'm using it incorrectly. I've copied the docs for this option verbatim but they are not clear and should be revisited.