Skip to content

Commit c3a41f2

Browse files
authored
Merge pull request #130 from emacs-php/fix/phpactor-executable-minor-fix
Minor fixes for phpactor-executable
2 parents c42d582 + 1ca4885 commit c3a41f2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

phpactor.el

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ of GitHub.")
117117
(let ((vendor-executable (f-join phpactor-install-directory "vendor/bin/phpactor")))
118118
(if (file-exists-p vendor-executable)
119119
vendor-executable
120-
(warn "Phpactor not found. Please run phpactor-install-or-update")
120+
(warn "Phpactor not found. Please run `phpactor-install-or-update' command")
121121
nil)))
122122

123-
(defcustom phpactor-executable (phpactor--find-executable)
123+
(defcustom phpactor-executable (phpactor--find-executable)
124124
"Path to phpactor executable.
125-
It is recommemded not to customize this, but if you do, you'll
126-
have to ensure a compatible version of phpactor is used."
127-
:type '(string)
125+
It is recommemded not to customize this, but if you do, you'll
126+
have to ensure a compatible version of phpactor is used."
127+
:type 'string
128128
:safe #'stringp
129129
:group 'phpactor)
130130

@@ -133,6 +133,13 @@ of GitHub.")
133133
(prog1
134134
(setq phpactor-executable (phpactor--find-executable))
135135
(remove-hook 'compilation-finish-functions #'phpactor-reset-executable)))
136+
137+
(defun phpactor-ensure-executable ()
138+
"Ensure `phpactor' command installed."
139+
(interactive)
140+
(unless (and phpactor-executable (file-exists-p phpactor-executable))
141+
(phpactor-install-or-update)
142+
(phpactor-reset-executable)))
136143

137144
;; Utility functions
138145

@@ -550,7 +557,7 @@ function."
550557
(when (and version (not (equal phpactor--supported-rpc-version version)))
551558
(if phpactor-executable
552559
(error "Phpactor uses rpc protocol %s but this package requires %s" version phpactor--supported-rpc-version)
553-
(error "Phpactor should be upgraded. Please run phpactor-install-or-update")))
560+
(user-error "Phpactor should be upgraded. Please run `phpactor-install-or-update' command")))
554561
(phpactor--add-history 'phpactor-action-dispatch (list :action action :parameters parameters :version version))
555562
(let ((func (cdr-safe (assq (intern action) phpactor-action-table))))
556563
(if func

0 commit comments

Comments
 (0)