Skip to content

Commit

Permalink
refactor: don't error when .env is not present (#21879)
Browse files Browse the repository at this point in the history
Uses similar format to when the latest version of std is implicitly
being used.

Closes #21788
  • Loading branch information
iuioiua authored Jan 21, 2024
1 parent 983c745 commit b4990d1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,11 @@ impl CliOptions {

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")
log::info!(
"{} The `--env` flag was used, but the dotenv file '{}' was not found.",
colors::yellow("Warning"),
env_file_name
);
}
}

Expand Down
5 changes: 1 addition & 4 deletions cli/tests/integration/eval_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,5 @@ itest!(env_file {

itest!(env_file_missing {
args: "eval --env=missing console.log(Deno.env.get(\"ANOTHER_FOO\"))",
output_str: Some(
"error: Unable to load 'missing' environment variable file\n"
),
exit_code: 1,
output: "eval/env_file_missing.out",
});
5 changes: 1 addition & 4 deletions cli/tests/integration/run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,7 @@ itest!(env_file {

itest!(env_file_missing {
args: "run --env=missing --allow-env run/env_file.ts",
output_str: Some(
"error: Unable to load 'missing' environment variable file\n"
),
exit_code: 1,
output: "run/env_file_missing.out",
});

itest!(_091_use_define_for_class_fields {
Expand Down
2 changes: 2 additions & 0 deletions cli/tests/testdata/eval/env_file_missing.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Warning The `--env` flag was used, but the dotenv file 'missing' was not found.
undefined
4 changes: 4 additions & 0 deletions cli/tests/testdata/run/env_file_missing.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Warning The `--env` flag was used, but the dotenv file 'missing' was not found.
undefined
undefined
undefined

0 comments on commit b4990d1

Please sign in to comment.