2024-08-26 21:40:45 -07:00
|
|
|
(defun exec-command (command &key (env-vars nil))
|
|
|
|
(let* ((default-env '(("PATH" . "\"$PATH:./scripts\"")))
|
|
|
|
(combined-env (append default-env env-vars))
|
2024-09-01 14:29:08 -07:00
|
|
|
(cd-command "cd ./site ; ")
|
|
|
|
(full-command (format nil "~{~a=~a~} ; ~a~a"
|
2024-08-26 21:40:45 -07:00
|
|
|
(mapcan (lambda (kv) (list (car kv) (cdr kv)))
|
|
|
|
combined-env)
|
2024-09-01 14:29:08 -07:00
|
|
|
cd-command
|
2024-08-26 21:40:45 -07:00
|
|
|
command)))
|
|
|
|
(with-open-stream (output-stream
|
2024-09-01 14:29:08 -07:00
|
|
|
(ext:run-program "/bin/bash" :arguments (list "-c" full-command)
|
2024-08-26 21:40:45 -07:00
|
|
|
:output :stream))
|
|
|
|
(with-output-to-string (result)
|
|
|
|
(loop for line = (read-line output-stream nil nil)
|
|
|
|
while line do (format result "~a~%" line))))))
|
|
|
|
|