Skip to content

Commit

Permalink
Fix path for downloaded cheats (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
denisidoro authored Apr 11, 2021
1 parent 56ae9b8 commit d550b29
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "navi"
version = "2.15.0"
version = "2.15.1"
authors = ["Denis Isidoro <[email protected]>"]
edition = "2018"
description = "An interactive cheatsheet tool for the command-line"
Expand Down
9 changes: 5 additions & 4 deletions src/cmds/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -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);
Expand All @@ -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)?
);

Expand Down
20 changes: 11 additions & 9 deletions tests/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit d550b29

Please sign in to comment.