File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,9 @@ notes_dir="${configured_dir:-$HOME/notes}"
13
13
escaped_notes_dir=" $( printf " $notes_dir " | sed -e ' s/[]\/$*.^|[]/\\&/g' ) "
14
14
15
15
# Make sure the notes directory actually exists, and create it if it doesn't
16
- if [ ! -d " $notes_dir " ]; then
17
- mkdir -p " $notes_dir "
16
+ if ! $( mkdir -p " $notes_dir " ) ; then
17
+ echo " Could not create directory $notes_dir , please update your \$ NOTES_DIRECTORY" >&2
18
+ exit 1
18
19
fi
19
20
20
21
# If no $EDITOR, look for `editor` (symlink on debian/ubuntu/etc)
Original file line number Diff line number Diff line change @@ -42,3 +42,21 @@ notes="./notes"
42
42
assert_success
43
43
assert_exists " $NOTES_DIRECTORY /test.txt"
44
44
}
45
+
46
+ @test " Configuration should be accepted if NOTES_DIR doesn't exist" {
47
+ mkdir -p $HOME /.config/notes
48
+ echo " NOTES_DIRECTORY=$NOTES_DIRECTORY /notesdir" > $HOME /.config/notes/config
49
+ run $notes new test
50
+
51
+ assert_success
52
+ }
53
+
54
+ @test " Configuration should be rejected if NOTES_DIR is a existing file" {
55
+ mkdir -p $HOME /.config/notes
56
+ touch $NOTES_DIRECTORY /testfile
57
+ echo " NOTES_DIRECTORY=$NOTES_DIRECTORY /testfile" > $HOME /.config/notes/config
58
+ run $notes new test
59
+
60
+ assert_failure
61
+ assert_line " Could not create directory $NOTES_DIRECTORY /testfile, please update your \$ NOTES_DIRECTORY"
62
+ }
You can’t perform that action at this time.
0 commit comments