Skip to content

Commit 05fe1f8

Browse files
committed
feat: Add clean dist
1 parent 0532217 commit 05fe1f8

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

lisp/_prepare.lisp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ to actually set up the systems."
494494
;; NOTE: Use this as project root?
495495
(defun qob-primary-root ()
496496
"Return the primary system path."
497-
(let ((path (car (cdr (qob-primary-system-entry)))))
497+
(let ((path (cdr (qob-primary-system-entry))))
498498
(qob-file-name-directory path)))
499499

500500
(defun qob-find-asd-file (name)
@@ -608,6 +608,11 @@ Set up the systems; on contrary, you should use the function
608608
(defvar qob-dist-path "dist/"
609609
"Default path where to place the package artifact.")
610610

611+
(defun qob-dist-path ()
612+
"Path to dist path."
613+
(let ((path (or (qob-args 0) qob-dist-path)))
614+
(qob-expand-fn path)))
615+
611616
;;
612617
;;; Entry
613618

@@ -693,4 +698,10 @@ Set up the systems; on contrary, you should use the function
693698
(qob-msg "✓ Loading Qob file in ~A... done!" qob-file)
694699
(qob-msg "✗ Loading Qob file... missing!")))))
695700

701+
;;
702+
;;; Commad variables
703+
704+
(defvar qob-no-cleaning-operation-p nil
705+
"Set to non-nil if there is no cleaning operation done.")
706+
696707
;;; End of lisp/_prepare.lisp

lisp/clean/dist.lisp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,30 @@
99

1010
;;; Code
1111

12+
(defun qob-clean-dist ()
13+
"Clean up the dist files."
14+
(let* ((name (qob-primary-system-name))
15+
(system (qob-primary-system))
16+
(version (asdf:component-version system))
17+
(f-name (qob-format "~A-~A" name version))
18+
(f-tar (qob-expand-fn (qob-format "~A.tar" f-name) qob-dist-path))
19+
(deleted 0)
20+
(delete-dir nil))
21+
(when (probe-file f-tar)
22+
(ignore-errors (delete-file f-tar))
23+
(incf deleted))
24+
(setq delete-dir (ignore-errors (uiop:delete-empty-directory qob-dist-path)))
25+
(qob-msg "")
26+
(qob-info "(Total of ~A file~A and ~A directory deleted)" deleted
27+
(qob--sinr deleted "" "s")
28+
(if delete-dir "1" "0"))))
29+
1230
(qob-start
13-
;; TODO: ..
14-
)
31+
(let ((qob-dist-path (qob-dist-path)))
32+
(if (probe-file qob-dist-path)
33+
(qob-clean-dist)
34+
(progn
35+
(qob-info "(No dist folder needs to be cleaned)" qob-dist-path)
36+
(setq qob-no-cleaning-operation-p t)))))
1537

1638
;;; End of lisp/clean/dist.lisp

lisp/core/package.lisp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
(ignore-errors (delete-directory f-dir :recursive t))
2424
(ensure-directories-exist f-dir)
2525

26+
;; Copy files over
2627
(dolist (path (qob-system-files))
2728
(let* ((path (qob-2str path))
2829
(rel-path (qob-s-replace root "" path))
@@ -41,12 +42,14 @@
4142
(qob-s-remove-prefix
4243
(qob-2str qob-dist-path)
4344
tar))))
45+
;; Delete cache folder
46+
(ignore-errors (delete-directory f-dir :recursive t))
47+
4448
(qob-msg "")
4549
(qob-info "(Built in ~A.tar)" tar)))
4650

4751
(qob-start
48-
(let* ((qob-dist-path (or (qob-args 0) qob-dist-path))
49-
(qob-dist-path (qob-expand-fn qob-dist-path)))
52+
(let ((qob-dist-path (qob-dist-path)))
5053
(ensure-directories-exist qob-dist-path)
5154

5255
(let ((name (qob-primary-system-name))

0 commit comments

Comments
 (0)