mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 19:08:15 +00:00
feat(unstable): deno run --env
(#20300)
This change adds the `--env=[FILE]` flag to the `run`, `compile`, `eval`, `install` and `repl` subcommands. Environment variables set in the CLI overwrite those defined in the `.env` file.
This commit is contained in:
parent
53248e9bb3
commit
f8f4e77632
10 changed files with 134 additions and 4 deletions
|
@ -52,6 +52,7 @@ use deno_runtime::deno_tls::rustls_pemfile;
|
|||
use deno_runtime::deno_tls::webpki_roots;
|
||||
use deno_runtime::inspector_server::InspectorServer;
|
||||
use deno_runtime::permissions::PermissionsOptions;
|
||||
use dotenvy::from_filename;
|
||||
use once_cell::sync::Lazy;
|
||||
use once_cell::sync::OnceCell;
|
||||
use serde::Deserialize;
|
||||
|
@ -651,6 +652,12 @@ impl CliOptions {
|
|||
let maybe_vendor_folder =
|
||||
resolve_vendor_folder(&initial_cwd, &flags, maybe_config_file.as_ref());
|
||||
|
||||
if let Some(env_file_name) = &flags.env_file {
|
||||
if (from_filename(env_file_name)).is_err() {
|
||||
bail!("Unable to load '{env_file_name}' environment variable file")
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
flags,
|
||||
initial_cwd,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue