Fix doom-sh/doom-sudo + bootstraps

This commit is contained in:
Henrik Lissner 2017-03-23 02:13:11 -04:00
parent 530935ae02
commit d0b64860e1
2 changed files with 9 additions and 6 deletions

View file

@ -21,10 +21,14 @@
(defun doom-sh (command &rest args) (defun doom-sh (command &rest args)
"Runs a shell command and prints any output to the DOOM buffer." "Runs a shell command and prints any output to the DOOM buffer."
(let ((cmd-list (split-string command " "))) (let ((cmd-list (split-string command " ")))
(if (equal (car cmd-list) "sudo") (cond ((equal (car cmd-list) "sudo")
(apply 'doom-sudo (string-join (cdr command) " ") args) (apply 'doom-sudo (string-join (cdr cmd-list) " ") args))
(let ((buf (get-buffer-create "*doom-sh*"))) ((let ((bin (executable-find "npm")))
(shell-command (apply 'format command args) buf))))) (and (file-exists-p bin)
(not (file-writable-p bin))))
(apply 'doom-sudo (string-join cmd-list " ") args))
(t
(princ (shell-command-to-string (apply 'format command args)))))))
;;;###autoload ;;;###autoload
(defun doom-sudo (command &rest args) (defun doom-sudo (command &rest args)
@ -33,7 +37,7 @@
(with-current-buffer (get-buffer-create "*doom-sudo*") (with-current-buffer (get-buffer-create "*doom-sudo*")
(unless (string-prefix-p "/sudo::/" default-directory) (unless (string-prefix-p "/sudo::/" default-directory)
(cd "/sudo::/")) (cd "/sudo::/"))
(apply 'doom-sh command args)))) (princ (shell-command-to-string (apply 'format command args))))))
;;;###autoload ;;;###autoload
(defun doom-fetch (fetcher location dest) (defun doom-fetch (fetcher location dest)

View file

@ -243,7 +243,6 @@ executed when called with `set!'. FORMS are not evaluated until `set!' calls it.
`(push (cons ',name `(push (cons ',name
(lambda () (lambda ()
(cl-flet ((sh (lambda (&rest args) (apply 'doom-sh args))) (cl-flet ((sh (lambda (&rest args) (apply 'doom-sh args)))
(sh& (lambda (&rest args) (apply 'doom-async-sh args)))
(sudo (lambda (&rest args) (apply 'doom-sudo args))) (sudo (lambda (&rest args) (apply 'doom-sudo args)))
(fetch (lambda (&rest args) (apply 'doom-fetch args))) (fetch (lambda (&rest args) (apply 'doom-fetch args)))
(message (lambda (&rest args) (message (lambda (&rest args)