doom/purge: refactor & optimize

Reduce how much work it had to do.
This commit is contained in:
Henrik Lissner 2020-05-25 15:53:09 -04:00
parent 944d7ec83f
commit 0bc3f8ea87
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -404,31 +404,31 @@ If ELPA-P, include packages installed with package.el (M-x package-install)."
(doom--barf-if-incomplete-packages) (doom--barf-if-incomplete-packages)
(print! (start "Purging orphaned packages (for the emperor)...")) (print! (start "Purging orphaned packages (for the emperor)..."))
(cl-destructuring-bind (&optional builds-to-purge repos-to-purge repos-to-regraft) (cl-destructuring-bind (&optional builds-to-purge repos-to-purge repos-to-regraft)
(let ((rdirs (straight--directory-files (straight--repos-dir) nil nil 'sort)) (let ((rdirs
(bdirs (straight--directory-files (straight--build-dir) nil nil 'sort))) (and (or repos-p regraft-repos-p)
(list (seq-remove (doom-rpartial #'gethash straight--profile-cache) (straight--directory-files (straight--repos-dir) nil nil 'sort))))
bdirs) (list (when builds-p
(seq-remove (doom-rpartial #'gethash straight--profile-cache)
(straight--directory-files (straight--build-dir) nil nil 'sort)))
(when repos-p
(seq-remove (doom-rpartial #'straight--checkhash straight--repo-cache) (seq-remove (doom-rpartial #'straight--checkhash straight--repo-cache)
rdirs) rdirs))
(when regraft-repos-p
(seq-filter (doom-rpartial #'straight--checkhash straight--repo-cache) (seq-filter (doom-rpartial #'straight--checkhash straight--repo-cache)
rdirs))) rdirs))))
(let (success)
(print-group! (print-group!
(delq
nil (list
(if (not builds-p) (if (not builds-p)
(print! (info "Skipping builds")) (ignore (print! (info "Skipping builds")))
(and (/= 0 (doom--cli-packages-purge-builds builds-to-purge)) (and (/= 0 (doom--cli-packages-purge-builds builds-to-purge))
(setq success t)
(straight-prune-build-cache))) (straight-prune-build-cache)))
(if (not elpa-p) (if (not elpa-p)
(print! (info "Skipping elpa packages")) (ignore (print! (info "Skipping elpa packages")))
(and (/= 0 (doom--cli-packages-purge-elpa)) (/= 0 (doom--cli-packages-purge-elpa)))
(setq success t)))
(if (not repos-p) (if (not repos-p)
(print! (info "Skipping repos")) (ignore (print! (info "Skipping repos")))
(and (/= 0 (doom--cli-packages-purge-repos repos-to-purge)) (/= 0 (doom--cli-packages-purge-repos repos-to-purge)))
(setq success t)))
(if (not regraft-repos-p) (if (not regraft-repos-p)
(print! (info "Skipping regrafting")) (ignore (print! (info "Skipping regrafting")))
(and (doom--cli-packages-regraft-repos repos-to-regraft) (doom--cli-packages-regraft-repos repos-to-regraft)))))))
(setq success t)))
success))))