Skip to content

Commit 3f4cb64

Browse files
authored
Merge pull request #44 from tardypad/install_config
Fix Makefile and don't overwrite config file if already present
2 parents e44434d + e98fb4c commit 3f4cb64

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Makefile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
PREFIX ?= /usr/local
2-
BASH_COMPLETION_DIR := $(shell pkg-config --silence-errors --variable=completionsdir bash-completion)
3-
# pkg-config adds a space for some reason, we have to strip it off.
4-
BASH_COMPLETION_DIR := $(strip $(BASH_COMPLETION_DIR))
2+
BASH_COMPLETION_DIR := $(shell pkg-config --silence-errors --variable=completionsdir bash-completion)
53
USERDIR ?= $(HOME)
64

75
# The @ symbols make the output silent.
@@ -16,21 +14,27 @@ If you have bash completion installed, follow the README \
1614
(https://github.com/pimterry/notes#installing-bash-completion) \
1715
to manually install it.\n\n"; \
1816
fi # Small test for bash completion support
17+
1918
@install -m755 -d $(PREFIX)/bin/
2019
@install -m755 notes $(PREFIX)/bin/
21-
@install -m777 -d $(USERDIR)/.config/notes/
22-
@install -m777 config $(USERDIR)/.config/notes/
2320
@install -d $(PREFIX)/share/man/man1/
2421
@install notes.1 $(PREFIX)/share/man/man1/
2522

2623
@mandb 1>/dev/null 2>&1 || true # Fail silently if we don't have a mandb
2724

25+
@printf "Notes has been installed to $(PREFIX)/bin/notes.\n"
26+
27+
@if [ ! -f $(USERDIR)/.config/notes/config ]; then \
28+
install -m777 -d $(USERDIR)/.config/notes/; \
29+
install -m777 config $(USERDIR)/.config/notes/; \
30+
printf \
31+
"A configuration file has also been created at $(USERDIR)/.config/notes/config, \
32+
which you can edit if you'd like to change the default settings.\n"; \
33+
fi # install default config file if non present
34+
2835
@printf \
29-
"Notes has been installed to $(PREFIX)/bin/notes. \
30-
A configuration file has also been created at $(USERDIR)/.config/notes/config, \
31-
which you can edit if you'd like to change the default settings.\n\n\
32-
Get started now by running 'notes new my-note' \
33-
or you can run 'notes help' for more info.\n"
36+
"\nGet started now by running 'notes new my-note' \
37+
or you can run 'notes help' for more info.\n"; \
3438

3539
uninstall:
3640
rm -f $(PREFIX)/bin/notes

0 commit comments

Comments
 (0)