Make dotenv-path
relative to working directory (#2040)
This commit is contained in:
parent
caace0a115
commit
07aaa4f440
@ -23,7 +23,7 @@ pub(crate) fn load_dotenv(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(path) = dotenv_path {
|
if let Some(path) = dotenv_path {
|
||||||
return load_from_file(path);
|
return load_from_file(&working_directory.join(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
let filename = dotenv_filename.map_or(DEFAULT_DOTENV_FILENAME, |s| s.as_str());
|
let filename = dotenv_filename.map_or(DEFAULT_DOTENV_FILENAME, |s| s.as_str());
|
||||||
|
@ -245,3 +245,20 @@ fn program_argument_has_priority_for_dotenv_path() {
|
|||||||
.status(EXIT_SUCCESS)
|
.status(EXIT_SUCCESS)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn dotenv_path_is_relative_to_working_directory() {
|
||||||
|
Test::new()
|
||||||
|
.justfile(
|
||||||
|
"
|
||||||
|
set dotenv-path := '.env'
|
||||||
|
|
||||||
|
foo:
|
||||||
|
@echo $DOTENV_KEY
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.tree(tree! { subdir: { } })
|
||||||
|
.current_dir("subdir")
|
||||||
|
.stdout("dotenv-value\n")
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
@ -203,9 +203,7 @@ impl Test {
|
|||||||
};
|
};
|
||||||
let stderr = unindent(&self.stderr);
|
let stderr = unindent(&self.stderr);
|
||||||
|
|
||||||
let mut dotenv_path = self.tempdir.path().to_path_buf();
|
fs::write(self.tempdir.path().join(".env"), "DOTENV_KEY=dotenv-value").unwrap();
|
||||||
dotenv_path.push(".env");
|
|
||||||
fs::write(dotenv_path, "DOTENV_KEY=dotenv-value").unwrap();
|
|
||||||
|
|
||||||
let mut command = Command::new(executable_path("just"));
|
let mut command = Command::new(executable_path("just"));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user