Allow fallback with search directory (#1348)
This loosens a restriction, and allows falling back to a justfile in a parent justfile
when a search directory is provide, e.g. with `just ..` or `just foo/bar/`. Looking
at it now, I can't really think of why I enforced that restriction in the first place.
Hopefully it's not important 🤷♀️.
This commit is contained in:
parent
e5350926b5
commit
76bda4cfd9
@ -92,8 +92,19 @@ impl Subcommand {
|
|||||||
arguments: &[String],
|
arguments: &[String],
|
||||||
overrides: &BTreeMap<String, String>,
|
overrides: &BTreeMap<String, String>,
|
||||||
) -> Result<(), Error<'src>> {
|
) -> Result<(), Error<'src>> {
|
||||||
if config.unstable && config.search_config == SearchConfig::FromInvocationDirectory {
|
if config.unstable
|
||||||
let mut path = config.invocation_directory.clone();
|
&& matches!(
|
||||||
|
config.search_config,
|
||||||
|
SearchConfig::FromInvocationDirectory | SearchConfig::FromSearchDirectory { .. }
|
||||||
|
)
|
||||||
|
{
|
||||||
|
let mut path = match &config.search_config {
|
||||||
|
SearchConfig::FromInvocationDirectory => config.invocation_directory.clone(),
|
||||||
|
SearchConfig::FromSearchDirectory { search_directory } => std::env::current_dir()
|
||||||
|
.unwrap()
|
||||||
|
.join(search_directory.clone()),
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
let mut unknown_recipes_errors = None;
|
let mut unknown_recipes_errors = None;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ fn requires_unstable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn doesnt_work_with_search_directory() {
|
fn works_with_provided_search_directory() {
|
||||||
Test::new()
|
Test::new()
|
||||||
.tree(tree! {
|
.tree(tree! {
|
||||||
bar: {
|
bar: {
|
||||||
@ -100,9 +100,15 @@ fn doesnt_work_with_search_directory() {
|
|||||||
",
|
",
|
||||||
)
|
)
|
||||||
.args(&["--unstable", "./foo"])
|
.args(&["--unstable", "./foo"])
|
||||||
|
.stdout("root\n")
|
||||||
|
.stderr(format!(
|
||||||
|
"
|
||||||
|
Trying ..{}justfile
|
||||||
|
echo root
|
||||||
|
",
|
||||||
|
MAIN_SEPARATOR
|
||||||
|
))
|
||||||
.current_dir("bar")
|
.current_dir("bar")
|
||||||
.status(EXIT_FAILURE)
|
|
||||||
.stderr("error: Justfile does not contain recipe `foo`.\n")
|
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user