diff --git a/Cargo.lock b/Cargo.lock index 74200ea5..dbc2046e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -308,7 +308,7 @@ dependencies = [ [[package]] name = "navi" -version = "2.15.0" +version = "2.15.1" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 8b7da9bc..dac5884d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "navi" -version = "2.15.0" +version = "2.15.1" authors = ["Denis Isidoro "] edition = "2018" description = "An interactive cheatsheet tool for the command-line" diff --git a/src/cmds/repo.rs b/src/cmds/repo.rs index 8d8dbd38..d145a26d 100644 --- a/src/cmds/repo.rs +++ b/src/cmds/repo.rs @@ -116,7 +116,7 @@ pub fn add(uri: String, finder: &FinderChoice) -> Result<(), Error> { }; let to_folder = { - let mut p = cheat_pathbuf.clone(); + let mut p = cheat_pathbuf; p.push(format!("{}__{}", user, repo)); p }; @@ -127,7 +127,9 @@ pub fn add(uri: String, finder: &FinderChoice) -> Result<(), Error> { p.push(file); p }; - let filename = file.replace("/", "__"); + let filename = file + .replace(&format!("{}/", &tmp_path_str), "") + .replace("/", "__"); let to = { let mut p = to_folder.clone(); p.push(filename); @@ -146,9 +148,8 @@ pub fn add(uri: String, finder: &FinderChoice) -> Result<(), Error> { filesystem::remove_dir(&tmp_pathbuf)?; eprintln!( - "The following .cheat files were imported successfully:\n{}\n\nThey are now located at {}/{}", + "The following .cheat files were imported successfully:\n{}\n\nThey are now located at {}", files, - pathbuf_to_string(&cheat_pathbuf)?, pathbuf_to_string(&to_folder)? ); diff --git a/tests/run b/tests/run index ec4fd616..b582b717 100755 --- a/tests/run +++ b/tests/run @@ -111,8 +111,10 @@ _integration() { sleep 1 tmux send-key -t ci "Enter" + echoerr "Checking paths..." sleep 2 - cat "$log_file" | tail -n10 | grep -q "/navi" + local -r downloaded_path="$(cat "$log_file" | grep 'They are now located at' | sed 's/They are now located at //')" + ls "$downloaded_path" | grep -q '^pkg_mgr__brew.cheat$' } if ! command_exists fzf; then @@ -140,19 +142,19 @@ for i in $(_get_tests "$filter"); do test::run "$query" _navi_cases_test "$query" "$expected" done -test::set_suite "3rd party" -test::run "tldr" _navi_tldr -test::run "cheatsh" _navi_cheatsh +test::set_suite "info" +test::run "cheats_path" _navi_cheatspath + +test::set_suite "integration" +test::run "welcome->pwd" _integration test::set_suite "widget" test::run "bash" _navi_widget "bash" test::run "zsh" _navi_widget "zsh" test::run "zsh" _navi_widget "fish" -test::set_suite "info" -test::run "cheats_path" _navi_cheatspath - -test::set_suite "integration" -test::run "welcome->pwd" _integration +test::set_suite "3rd party" +test::run "tldr" _navi_tldr +test::run "cheatsh" _navi_cheatsh test::finish