Skip to content

Commit

Permalink
Merge pull request pimterry#6 from trengrj/check-editor
Browse files Browse the repository at this point in the history
Test if $EDITOR set, fail if no editor can be found.
  • Loading branch information
pimterry authored Dec 2, 2016
2 parents e13b18d + 49654ac commit 3e7bfee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions notes
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ open_note() {
if [ ! -f "$note_path" ]; then
note_path="$notes_dir/$note_path"
fi
if [ -z "$EDITOR" ]; then
printf "Please set \$EDITOR to edit notes\n"
exit 1
fi

$EDITOR "$note_path" < /dev/tty
}
Expand Down
7 changes: 7 additions & 0 deletions test/test-open.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ notes="./notes"
assert_output "Opening $HOME/notes"
}

@test "Exits if EDITOR not configured" {
unset EDITOR
run $notes open test

assert_failure
}

@test "Opens the configured notes directory if set" {
run $notes open

Expand Down

0 comments on commit 3e7bfee

Please sign in to comment.