diff --git a/src/search.rs b/src/search.rs index 5085419..4d061e0 100644 --- a/src/search.rs +++ b/src/search.rs @@ -4,6 +4,7 @@ const DEFAULT_JUSTFILE_NAME: &str = JUSTFILE_NAMES[0]; pub(crate) const JUSTFILE_NAMES: [&str; 2] = ["justfile", ".justfile"]; const PROJECT_ROOT_CHILDREN: &[&str] = &[".bzr", ".git", ".hg", ".svn", "_darcs"]; +#[derive(Debug)] pub(crate) struct Search { pub(crate) justfile: PathBuf, pub(crate) working_directory: PathBuf, diff --git a/src/subcommand.rs b/src/subcommand.rs index 6173bfd..65c80a8 100644 --- a/src/subcommand.rs +++ b/src/subcommand.rs @@ -110,9 +110,10 @@ impl Subcommand { ) { let starting_path = match &config.search_config { SearchConfig::FromInvocationDirectory => config.invocation_directory.clone(), - SearchConfig::FromSearchDirectory { search_directory } => { - env::current_dir().unwrap().join(search_directory) - } + SearchConfig::FromSearchDirectory { search_directory } => config + .invocation_directory + .join(search_directory) + .lexiclean(), _ => unreachable!(), }; diff --git a/tests/search.rs b/tests/search.rs index daac5bf..b7ebe47 100644 --- a/tests/search.rs +++ b/tests/search.rs @@ -143,6 +143,22 @@ fn single_upwards() { search_test(path, &["../"]); } +#[test] +fn double_upwards() { + let tmp = temptree! { + justfile: "default:\n\techo ok", + foo: { + bar: { + justfile: "default:\n\techo foo", + }, + }, + }; + + let path = tmp.path().join("foo/bar"); + + search_test(path, &["../default"]); +} + #[test] fn find_dot_justfile() { Test::new()