chore: executable-find checking before installing the deps

This commit is contained in:
Jason Tian 2023-10-30 16:24:04 +08:00
parent 4604a04498
commit 54aa9434bb

View file

@ -102,7 +102,7 @@
:darwin-command "brew install pyright"
;; :linux-command "pipx install pyright"
:linux-command "sudo pacman -S --noconfirm pyright"
:windows-command ""
:windows-command "npm install -g pyright"
:message nil ;; No message needed for pyright
:enabled t)
(prettier
@ -134,45 +134,46 @@ Display the MESSAGE if installation is skipped."
(msg (plist-get value :message))
(enabled (plist-get value :enabled)))
(when enabled
(cond
;; macOS condition
((and (eq system-type 'darwin)
command-darwin
(not (string-empty-p command-darwin)))
(my-install-dependency name command-darwin))
((and (eq system-type 'darwin)
(eq command-darwin nil))
(message "%s is not considered to install on macOS." name))
;; Linux condition
((and (eq system-type 'gnu/linux)
command-linux
(not (string-empty-p command-linux)))
(my-install-dependency name command-linux))
((and (eq system-type 'gnu/linux)
(eq command-linux nil))
(message "%s is not considered to install on Linux." name))
;; Windows condition
((and (eq system-type 'windows-nt)
command-windows
(not (string-empty-p command-windows)))
(my-install-dependency name
(format
"powershell -Command \"%s\""
command-windows)))
((and (eq system-type 'windows-nt)
(eq command-windows nil))
(message "%s is not considered to install on Windows." name))
;; for any other condition
(t
(let* ((msg-content
(if msg
msg
(format "%s executable is needed in this configuration file,
(unless (executable-find name)
(cond
;; macOS condition
((and (eq system-type 'darwin)
command-darwin
(not (string-empty-p command-darwin)))
(my-install-dependency name command-darwin))
((and (eq system-type 'darwin)
(eq command-darwin nil))
(message "%s is not considered to install on macOS." name))
;; Linux condition
((and (eq system-type 'gnu/linux)
command-linux
(not (string-empty-p command-linux)))
(my-install-dependency name command-linux))
((and (eq system-type 'gnu/linux)
(eq command-linux nil))
(message "%s is not considered to install on Linux." name))
;; Windows condition
((and (eq system-type 'windows-nt)
command-windows
(not (string-empty-p command-windows)))
(my-install-dependency name
(format
"powershell -Command \"%s\""
command-windows)))
((and (eq system-type 'windows-nt)
(eq command-windows nil))
(message "%s is not considered to install on Windows." name))
;; for any other condition
(t
(let* ((msg-content
(if msg
msg
(format "%s executable is needed in this configuration file,
check/install it manually." name)))
(prompt-msg (concat msg-content " Press ENTER to continue.")))
(when (string= (read-string prompt-msg) "")
(message "Continuing..."))
)))))))
(prompt-msg (concat msg-content " Press ENTER to continue.")))
(when (string= (read-string prompt-msg) "")
(message "Continuing..."))
))))))))
(progn