summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/args/mod.rs18
-rw-r--r--tests/specs/eval/env_unparsable_file/__test__.jsonc4
-rw-r--r--tests/specs/eval/env_unparsable_file/main.out2
-rw-r--r--tests/specs/run/env_unparsable_file/__test__.jsonc4
-rw-r--r--tests/specs/run/env_unparsable_file/main.js3
-rw-r--r--tests/specs/run/env_unparsable_file/main.out4
-rw-r--r--tests/testdata/env_unparsable4
-rw-r--r--tests/testdata/eval/env_file_missing.out2
-rw-r--r--tests/testdata/run/env_file_missing.out2
9 files changed, 34 insertions, 9 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index bc384a132..706d98852 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -857,13 +857,17 @@ impl CliOptions {
};
if let Some(env_file_name) = &flags.env_file {
- if (from_filename(env_file_name)).is_err() {
- log::info!(
- "{} The `--env` flag was used, but the dotenv file '{}' was not found.",
- colors::yellow("Warning"),
- env_file_name
- );
- }
+ match from_filename(env_file_name) {
+ Ok(_) => (),
+ Err(error) => {
+ match error {
+ dotenvy::Error::LineParse(line, index)=> log::info!("{} Parsing failed within the specified environment file: {} at index: {} of the value: {}",colors::yellow("Warning"), env_file_name, index, line),
+ dotenvy::Error::Io(_)=> log::info!("{} The `--env` flag was used, but the environment file specified '{}' was not found.",colors::yellow("Warning"),env_file_name),
+ dotenvy::Error::EnvVar(_)=>log::info!("{} One or more of the environment variables isn't present or not unicode within the specified environment file: {}",colors::yellow("Warning"),env_file_name),
+ _ => log::info!("{} Unknown failure occurred with the specified environment file: {}", colors::yellow("Warning"), env_file_name),
+ }
+ }
+ }
}
let disable_deprecated_api_warning = flags.log_level
diff --git a/tests/specs/eval/env_unparsable_file/__test__.jsonc b/tests/specs/eval/env_unparsable_file/__test__.jsonc
new file mode 100644
index 000000000..cf5e9a99b
--- /dev/null
+++ b/tests/specs/eval/env_unparsable_file/__test__.jsonc
@@ -0,0 +1,4 @@
+{
+ "args": "eval --env=../../../testdata/env_unparsable console.log(Deno.env.get(\"Another_FOO\"))",
+ "output": "main.out"
+}
diff --git a/tests/specs/eval/env_unparsable_file/main.out b/tests/specs/eval/env_unparsable_file/main.out
new file mode 100644
index 000000000..18d7856b4
--- /dev/null
+++ b/tests/specs/eval/env_unparsable_file/main.out
@@ -0,0 +1,2 @@
+Warning Parsing failed within the specified environment file: ../../../testdata/env_unparsable at index: 3 of the value: c:\path
+undefined
diff --git a/tests/specs/run/env_unparsable_file/__test__.jsonc b/tests/specs/run/env_unparsable_file/__test__.jsonc
new file mode 100644
index 000000000..bed150635
--- /dev/null
+++ b/tests/specs/run/env_unparsable_file/__test__.jsonc
@@ -0,0 +1,4 @@
+{
+ "args": "run --env=../../../testdata/env_unparsable --allow-env main.js",
+ "output": "main.out"
+}
diff --git a/tests/specs/run/env_unparsable_file/main.js b/tests/specs/run/env_unparsable_file/main.js
new file mode 100644
index 000000000..48488ce72
--- /dev/null
+++ b/tests/specs/run/env_unparsable_file/main.js
@@ -0,0 +1,3 @@
+console.log(Deno.env.get("FOO"));
+console.log(Deno.env.get("ANOTHER_FOO"));
+console.log(Deno.env.get("MULTILINE"));
diff --git a/tests/specs/run/env_unparsable_file/main.out b/tests/specs/run/env_unparsable_file/main.out
new file mode 100644
index 000000000..a19ff4dd6
--- /dev/null
+++ b/tests/specs/run/env_unparsable_file/main.out
@@ -0,0 +1,4 @@
+Warning Parsing failed within the specified environment file: ../../../testdata/env_unparsable at index: 3 of the value: c:\path
+valid
+undefined
+undefined
diff --git a/tests/testdata/env_unparsable b/tests/testdata/env_unparsable
new file mode 100644
index 000000000..5542b80bc
--- /dev/null
+++ b/tests/testdata/env_unparsable
@@ -0,0 +1,4 @@
+FOO=valid
+ANOTHER_FOO=c:\path
+MULTILINE="First Line
+Second Line" \ No newline at end of file
diff --git a/tests/testdata/eval/env_file_missing.out b/tests/testdata/eval/env_file_missing.out
index 221acab93..2ec371438 100644
--- a/tests/testdata/eval/env_file_missing.out
+++ b/tests/testdata/eval/env_file_missing.out
@@ -1,2 +1,2 @@
-Warning The `--env` flag was used, but the dotenv file 'missing' was not found.
+Warning The `--env` flag was used, but the environment file specified 'missing' was not found.
undefined
diff --git a/tests/testdata/run/env_file_missing.out b/tests/testdata/run/env_file_missing.out
index ae1f8f595..6ec9b298f 100644
--- a/tests/testdata/run/env_file_missing.out
+++ b/tests/testdata/run/env_file_missing.out
@@ -1,4 +1,4 @@
-Warning The `--env` flag was used, but the dotenv file 'missing' was not found.
+Warning The `--env` flag was used, but the environment file specified 'missing' was not found.
undefined
undefined
undefined