Skip to content

Commit d72bdfe

Browse files
committed
Make sure notes grep | notes open works (by not including file content in grep)
1 parent e08fd98 commit d72bdfe

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

notes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ grep_notes() {
2727
return 1
2828
fi
2929

30-
grep_output=$(grep -r "$notes_dir" -e "$*" 2>&1)
30+
grep_output=$(grep -r "$notes_dir" -l -e "$*" 2>&1)
3131
grep_result=$?
3232
formatted_output=$(printf "$grep_output" | without_notes_dir)
3333

test/test-grep.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ notes="./notes"
2828
run $notes grep my-pattern
2929

3030
assert_success
31-
assert_line "matching-node.md:my-pattern"
31+
assert_line "matching-node.md"
3232
refute_line "non-matching-node.md"
3333
}

test/test-open.bats

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ notes="./notes"
3535
assert_output "Opening $NOTES_DIRECTORY"
3636
}
3737

38-
@test "Opens a file passed by pipe if provided" {
38+
@test "Opens a file passed by pipe from find" {
3939
touch $NOTES_DIRECTORY/note.md
4040

4141
run bash -c "$notes find | $notes open"
@@ -44,7 +44,16 @@ notes="./notes"
4444
assert_output "Editing $NOTES_DIRECTORY/note.md"
4545
}
4646

47-
@test "Opens multiple files passed by pipe if provided" {
47+
@test "Opens a file passed by pipe from grep" {
48+
echo "hi" > $NOTES_DIRECTORY/note.md
49+
50+
run bash -c "$notes grep 'hi' | $notes open"
51+
52+
assert_success
53+
assert_output "Editing $NOTES_DIRECTORY/note.md"
54+
}
55+
56+
@test "Opens multiple files passed by pipe from find" {
4857
touch $NOTES_DIRECTORY/note.md
4958
touch $NOTES_DIRECTORY/note2.md
5059

0 commit comments

Comments
 (0)