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)
"Write all log buffers to their appropriate files."
;; Delete the last `doom-cli-log-retain' logs
(mapc #'delete-file
(let ((prefix (doom-cli-context-prefix context)))
(append (butlast (doom-glob (format doom-cli-log-file-format prefix "*" "log"))
doom-cli-log-retain)
(butlast (doom-glob (format doom-cli-log-file-format prefix "*" "error"))
doom-cli-log-retain))))
;; Then write the log file, if necessary
(let* ((buffer (doom-cli-context-stderr context))
(file (doom-cli--output-file "log" context)))
(when (> (buffer-size buffer) 0)
(make-directory (file-name-directory file) t)
(with-temp-file file
(insert-buffer-substring buffer)
(ansi-color-filter-region (point-min) (point-max)))
(set-file-modes file #o600))))
(when (/= doom-cli--exit-code 254)
;; Delete the last `doom-cli-log-retain' logs
(mapc #'delete-file
(let ((prefix (doom-cli-context-prefix context)))
(append (butlast (doom-glob (format doom-cli-log-file-format prefix "*" "log"))
doom-cli-log-retain)
(butlast (doom-glob (format doom-cli-log-file-format prefix "*" "error"))
doom-cli-log-retain))))
;; Then write the log file, if necessary
(let* ((buffer (doom-cli-context-stderr context))
(file (doom-cli--output-file "log" context)))
(when (> (buffer-size buffer) 0)
(make-directory (file-name-directory file) t)
(with-temp-file file
(insert-buffer-substring buffer)
(ansi-color-filter-region (point-min) (point-max)))
(set-file-modes file #o600)))))
(defun doom-cli--output-benchmark-h (context)
"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
(require 'doom-lib)
;; ...and in batch session, load our CLI framework
(when noninteractive
(require 'doom-cli-lib))
;;