Skip to content

Commit 6b4e272

Browse files
authored
feat: Add command to clean autoloads (#98)
* feat: Add command to clean autoloads * Impls all * add test * supply sec
1 parent 8486722 commit 6b4e272

File tree

7 files changed

+86
-20
lines changed

7 files changed

+86
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
3131
* Move command `activate` under test subcommand (#92)
3232
* Add command to create ELPA project (#94)
3333
* Add command to clean log files (#97)
34+
* Add command to clean autoloads file (#98)
3435

3536
## 0.7.x
3637
> Released Sep 08, 2022

cmds/clean/autoloads.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (C) 2023 Jen-Chieh Shen
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3, or (at your option)
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with GNU Emacs; see the file COPYING. If not, write to the
16+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17+
* Boston, MA 02110-1301, USA.
18+
*/
19+
20+
"use strict";
21+
22+
exports.command = ['autoloads'];
23+
exports.desc = 'Remove generated autoloads file';
24+
25+
exports.handler = async (argv) => {
26+
await UTIL.e_call(argv, 'clean/autoloads', argv.dest);
27+
};

docs/content/en/Getting Started/Commands and options.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,14 @@ $ eask [GLOBAL-OPTIONS] clean dist
356356

357357
Alias: `distribution`
358358

359+
## 🔍 eask clean autoloads
360+
361+
Remove generated autoloads file.
362+
363+
```sh
364+
$ eask [GLOBAL-OPTIONS] clean autoloads
365+
```
366+
359367
## 🔍 eask clean log-file
360368

361369
Remove all generated log files.
@@ -371,6 +379,7 @@ This command is the combination of all other clean commands.
371379
- `clean workspace`
372380
- `clean elc`
373381
- `clean dist`
382+
- `clean autoloads`
374383
- `clean log-file`
375384

376385
```sh

lisp/clean/all.el

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@
1717
(defvar eask-no-cleaning-operation-p nil
1818
"Set to non-nil if there is no cleaning operation done.")
1919

20+
(defmacro eask--clean-section (title &rest body)
21+
"Print clean up TITLE and execute BODY."
22+
(declare (indent 1))
23+
`(let (eask-no-cleaning-operation-p)
24+
(eask-with-progress
25+
(format "%s... \n" ,title)
26+
(progn ,@body)
27+
(if eask-no-cleaning-operation-p "skipped ✗" "done ✓"))))
28+
2029
(eask-start
21-
(let (eask-no-cleaning-operation-p)
22-
(eask-with-progress
23-
"Cleaning workspace... \n"
24-
(eask-call "clean/workspace")
25-
(if eask-no-cleaning-operation-p "skipped ✗" "done ✓")))
30+
(eask--clean-section "Cleaning workspace"
31+
(eask-call "clean/workspace"))
32+
(eask-msg "")
33+
(eask--clean-section "Cleaning byte-compile files"
34+
(eask-call "clean/elc"))
2635
(eask-msg "")
27-
(let (eask-no-cleaning-operation-p)
28-
(eask-with-progress
29-
"Cleaning byte-compile files... \n"
30-
(eask-call "clean/elc")
31-
(if eask-no-cleaning-operation-p "skipped ✗" "done ✓")))
36+
(eask--clean-section "Cleaning dist"
37+
(eask-call "clean/dist"))
3238
(eask-msg "")
33-
(let (eask-no-cleaning-operation-p)
34-
(eask-with-progress
35-
"Cleaning dist... \n"
36-
(eask-call "clean/dist")
37-
(if eask-no-cleaning-operation-p "skipped ✗" "done ✓")))
39+
(eask--clean-section "Cleaning autoloads file"
40+
(eask-call "clean/autoloads"))
3841
(eask-msg "")
39-
(let (eask-no-cleaning-operation-p)
40-
(eask-with-progress
41-
"Cleaning log files... \n"
42-
(eask-call "clean/log-file")
43-
(if eask-no-cleaning-operation-p "skipped ✗" "done ✓"))))
42+
(eask--clean-section "Cleaning log files"
43+
(eask-call "clean/log-file")))
4444

4545
;;; clean/all.el ends here

lisp/clean/autoloads.el

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
;;; clean/autoloads.el --- Remove generated autoloads file -*- lexical-binding: t; -*-
2+
3+
;;; Commentary:
4+
;;
5+
;; Remove generated autoloads file,
6+
;;
7+
;; $ eask clean autoloads
8+
;;
9+
10+
;;; Code:
11+
12+
(load (expand-file-name
13+
"../_prepare.el"
14+
(file-name-directory (nth 1 (member "-scriptload" command-line-args))))
15+
nil t)
16+
17+
(eask-start
18+
(let* ((name (eask-guess-package-name))
19+
(autoloads-file (expand-file-name (concat name "-autoloads.el")))
20+
(deleted (eask-delete-file autoloads-file)))
21+
(eask-msg "")
22+
(if deleted
23+
(eask-info "(Total of 1 file deleted)")
24+
(eask-info "(No autoloads file found in workspace)")
25+
(setq eask-no-cleaning-operation-p t))))
26+
27+
;;; clean/autoloads.el ends here

lisp/core/autoloads.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
(let* ((name (eask-guess-package-name))
1919
(autoloads-file (expand-file-name (concat name "-autoloads.el"))))
2020
(package-generate-autoloads name default-directory)
21+
(eask-msg "")
2122
(eask-info "Write file %s..." autoloads-file)))
2223

2324
;;; core/autoloads.el ends here

test/commands/local/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ eask test activate
7171
eask clean .eask
7272
eask clean elc
7373
eask clean dist
74+
eask clean autoloads
7475
eask clean log-file
7576
eask clean all
7677

0 commit comments

Comments
 (0)