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 #'straight--checkhash straight--repo-cache) (seq-remove (doom-rpartial #'gethash straight--profile-cache)
rdirs) (straight--directory-files (straight--build-dir) nil nil 'sort)))
(seq-filter (doom-rpartial #'straight--checkhash straight--repo-cache) (when repos-p
rdirs))) (seq-remove (doom-rpartial #'straight--checkhash straight--repo-cache)
(let (success) rdirs))
(print-group! (when regraft-repos-p
(if (not builds-p) (seq-filter (doom-rpartial #'straight--checkhash straight--repo-cache)
(print! (info "Skipping builds")) rdirs))))
(and (/= 0 (doom--cli-packages-purge-builds builds-to-purge)) (print-group!
(setq success t) (delq
(straight-prune-build-cache))) nil (list
(if (not elpa-p) (if (not builds-p)
(print! (info "Skipping elpa packages")) (ignore (print! (info "Skipping builds")))
(and (/= 0 (doom--cli-packages-purge-elpa)) (and (/= 0 (doom--cli-packages-purge-builds builds-to-purge))
(setq success t))) (straight-prune-build-cache)))
(if (not repos-p) (if (not elpa-p)
(print! (info "Skipping repos")) (ignore (print! (info "Skipping elpa packages")))
(and (/= 0 (doom--cli-packages-purge-repos repos-to-purge)) (/= 0 (doom--cli-packages-purge-elpa)))
(setq success t))) (if (not repos-p)
(if (not regraft-repos-p) (ignore (print! (info "Skipping repos")))
(print! (info "Skipping regrafting")) (/= 0 (doom--cli-packages-purge-repos repos-to-purge)))
(and (doom--cli-packages-regraft-repos repos-to-regraft) (if (not regraft-repos-p)
(setq success t))) (ignore (print! (info "Skipping regrafting")))
success)))) (doom--cli-packages-regraft-repos repos-to-regraft)))))))