diff options
| author | David Shepherd <davidshepherd7@gmail.com> | 2017-03-16 12:54:23 +0000 |
|---|---|---|
| committer | David Shepherd <davidshepherd7@gmail.com> | 2017-03-16 13:07:27 +0000 |
| commit | 7682b2c5ddaeb5a795fe253f4d8f30ae7cef0764 (patch) | |
| tree | c5117ebe0fe0a2ce1041ff48a7d1d2db044e2a71 | |
| parent | Tidy up (diff) | |
| download | emacs-terminal-here-7682b2c5ddaeb5a795fe253f4d8f30ae7cef0764.tar.gz | |
Avoid calling vc-root-dir when it doesn't exist
| -rw-r--r-- | terminal-here.el | 7 | ||||
| -rw-r--r-- | test/terminal-here-test.el | 8 |
2 files changed, 12 insertions, 3 deletions
diff --git a/terminal-here.el b/terminal-here.el index 62c4a43..9ba5e32 100644 --- a/terminal-here.el +++ b/terminal-here.el @@ -69,9 +69,10 @@ changed it by running `cd'." If projectile is installed the projectile root will be used, Otherwise `vc-root-dir' will be used." (interactive) - (terminal-here-launch-in-directory (if (functionp 'projectile-project-root) - (projectile-project-root) - (vc-root-dir)))) + (terminal-here-launch-in-directory (cond + ((and (functionp 'projectile-project-root) (projectile-project-root))) + ((and (functionp 'vc-root-dir) (vc-root-dir))) + (t (signal 'user-error "Failed to detect project root, if you are in a version-controlled project try installing projectile or upgrading to emacs 25"))))) diff --git a/test/terminal-here-test.el b/test/terminal-here-test.el index e30a238..24f5ca4 100644 --- a/test/terminal-here-test.el +++ b/test/terminal-here-test.el @@ -55,3 +55,11 @@ (mock (vc-root-dir) => "vc-root") (mock (terminal-here-launch-in-directory "vc-root")) (terminal-here-project-launch))) + +(ert-deftest no-root-found () + (with-mock + (mock (projectile-project-root) => nil) + (mock (vc-root-dir) => nil) + (should-error + (terminal-here-project-launch) + :type 'user-error))) |
