diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-01-22 10:27:14 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 00:27:14 +0100 |
commit | b4990d1aa233db662cf22d7f872d45b3a947e0f6 (patch) | |
tree | 7009b20a5d05e5e2e2d3d9c79fdd8974347f69a3 | |
parent | 983c745d4f385594638c42c107dca7d55afd0731 (diff) |
refactor: don't error when `.env` is not present (#21879)
Uses similar format to when the latest version of std is implicitly
being used.
Closes #21788
-rw-r--r-- | cli/args/mod.rs | 6 | ||||
-rw-r--r-- | cli/tests/integration/eval_tests.rs | 5 | ||||
-rw-r--r-- | cli/tests/integration/run_tests.rs | 5 | ||||
-rw-r--r-- | cli/tests/testdata/eval/env_file_missing.out | 2 | ||||
-rw-r--r-- | cli/tests/testdata/run/env_file_missing.out | 4 |
5 files changed, 13 insertions, 9 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 2657ed385..1fdd2f503 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -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 + ); } } diff --git a/cli/tests/integration/eval_tests.rs b/cli/tests/integration/eval_tests.rs index 5d0566a19..1ae65e49e 100644 --- a/cli/tests/integration/eval_tests.rs +++ b/cli/tests/integration/eval_tests.rs @@ -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", }); diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 4e3fa8de2..d7d65726e 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -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 { diff --git a/cli/tests/testdata/eval/env_file_missing.out b/cli/tests/testdata/eval/env_file_missing.out new file mode 100644 index 000000000..221acab93 --- /dev/null +++ b/cli/tests/testdata/eval/env_file_missing.out @@ -0,0 +1,2 @@ +Warning The `--env` flag was used, but the dotenv file 'missing' was not found. +undefined diff --git a/cli/tests/testdata/run/env_file_missing.out b/cli/tests/testdata/run/env_file_missing.out new file mode 100644 index 000000000..ae1f8f595 --- /dev/null +++ b/cli/tests/testdata/run/env_file_missing.out @@ -0,0 +1,4 @@ +Warning The `--env` flag was used, but the dotenv file 'missing' was not found. +undefined +undefined +undefined |