fix(cli): duplicate log files

This commit is contained in:
Henrik Lissner 2022-09-06 21:46:29 +02:00
parent aef14f078d
commit c370cb1784
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
2 changed files with 17 additions and 19 deletions

View file

@ -1030,22 +1030,23 @@ See `doom-cli-log-file-format' for details."
(defun doom-cli--output-write-logs-h (context) (defun doom-cli--output-write-logs-h (context)
"Write all log buffers to their appropriate files." "Write all log buffers to their appropriate files."
;; Delete the last `doom-cli-log-retain' logs (when (/= doom-cli--exit-code 254)
(mapc #'delete-file ;; Delete the last `doom-cli-log-retain' logs
(let ((prefix (doom-cli-context-prefix context))) (mapc #'delete-file
(append (butlast (doom-glob (format doom-cli-log-file-format prefix "*" "log")) (let ((prefix (doom-cli-context-prefix context)))
doom-cli-log-retain) (append (butlast (doom-glob (format doom-cli-log-file-format prefix "*" "log"))
(butlast (doom-glob (format doom-cli-log-file-format prefix "*" "error")) doom-cli-log-retain)
doom-cli-log-retain)))) (butlast (doom-glob (format doom-cli-log-file-format prefix "*" "error"))
;; Then write the log file, if necessary doom-cli-log-retain))))
(let* ((buffer (doom-cli-context-stderr context)) ;; Then write the log file, if necessary
(file (doom-cli--output-file "log" context))) (let* ((buffer (doom-cli-context-stderr context))
(when (> (buffer-size buffer) 0) (file (doom-cli--output-file "log" context)))
(make-directory (file-name-directory file) t) (when (> (buffer-size buffer) 0)
(with-temp-file file (make-directory (file-name-directory file) t)
(insert-buffer-substring buffer) (with-temp-file file
(ansi-color-filter-region (point-min) (point-max))) (insert-buffer-substring buffer)
(set-file-modes file #o600)))) (ansi-color-filter-region (point-min) (point-max)))
(set-file-modes file #o600)))))
(defun doom-cli--output-benchmark-h (context) (defun doom-cli--output-benchmark-h (context)
"Write this session's benchmark to stdout or stderr, depending. "Write this session's benchmark to stdout or stderr, depending.

View file

@ -355,9 +355,6 @@ Otherwise, `en/disable-command' (in novice.el.gz) is hardcoded to write them to
;; ...then load *the* one ;; ...then load *the* one
(require 'doom-lib) (require 'doom-lib)
;; ...and in batch session, load our CLI framework
(when noninteractive
(require 'doom-cli-lib))
;; ;;