Skip to content

Commit d470a92

Browse files
authored
feat(cmds): Add recompile command (#254)
* feat(cmds): Add recompile command * Changelog * fix copyright year * fix: load script messages * test recompile --clean
1 parent 754fdc1 commit d470a92

File tree

11 files changed

+111
-10
lines changed

11 files changed

+111
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
2626
* fix: Don't pollute outer programs (#239)
2727
* feat(generate/test): Add commands to setup test files (#243)
2828
* feat: Add `docs` command (#245)
29+
* feat(cmds): Add `recompile` command (#254)
2930

3031
## 0.9.x
3132
> Released Nov 17, 2023

cmds/core/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"use strict";
1919

2020
exports.command = ['compile [names..]'];
21-
exports.desc = 'Byte compile all Emacs Lisp files in the package';
21+
exports.desc = "Byte-compile `.el' files";
2222
exports.builder = yargs => yargs
2323
.positional(
2424
'[names..]', {

cmds/core/recompile.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright (C) 2024 the Eask authors.
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 this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
"use strict";
19+
20+
exports.command = ['recompile [names..]'];
21+
exports.desc = "Byte-recompile `.el' files";
22+
exports.builder = yargs => yargs
23+
.positional(
24+
'[names..]', {
25+
description: 'specify files to byte-compile',
26+
type: 'array',
27+
})
28+
.options({
29+
'clean': {
30+
description: 'clean byte-recompile files individually',
31+
type: 'boolean',
32+
group: TITLE_CMD_OPTION,
33+
},
34+
});
35+
36+
exports.handler = async (argv) => {
37+
await UTIL.e_call(argv, 'core/recompile'
38+
, argv.names
39+
, UTIL.def_flag(argv.clean, '--clean'));
40+
};

docs/content/Getting-Started/Basic-Usage/_index.en.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ Commands:
3535
analyze [files..] Run Eask checker
3636
archives List out all package archives [aliases: sources]
3737
clean <type> Delete various files produced during building
38-
compile [names..] Byte compile all Emacs Lisp files in the package
38+
compile [names..] Byte-compile `.el' files
3939
create <type> Create a new elisp project
4040
docker <version> [args..] Launch specified Emacs version in a Docker container
41-
docs Build documentation [aliases: doc]
41+
docs [names..] Build documentation [aliases: doc]
4242
emacs [args..] Execute emacs with the appropriate environment
4343
eval [form] Evaluate lisp form with a proper PATH
4444
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
@@ -60,6 +60,7 @@ Commands:
6060
package-directory Print path to package directory
6161
package [destination] Build a package artifact, and put it into the given destination [aliases: pack]
6262
recipe Suggest a recipe format
63+
recompile [names..] Byte-recompile `.el' files
6364
refresh Download package archives
6465
reinstall [names..] Reinstall packages
6566
run <type> Run custom tasks

docs/content/Getting-Started/Basic-Usage/_index.zh-tw.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ Commands:
3232
analyze [files..] Run Eask checker
3333
archives List out all package archives [aliases: sources]
3434
clean <type> Delete various files produced during building
35-
compile [names..] Byte compile all Emacs Lisp files in the package
35+
compile [names..] Byte-compile `.el' files
3636
create <type> Create a new elisp project
3737
docker <version> [args..] Launch specified Emacs version in a Docker container
38-
docs Build documentation [aliases: doc]
38+
docs [names..] Build documentation [aliases: doc]
3939
emacs [args..] Execute emacs with the appropriate environment
4040
eval [form] Evaluate lisp form with a proper PATH
4141
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
@@ -57,6 +57,7 @@ Commands:
5757
package-directory Print path to package directory
5858
package [destination] Build a package artifact, and put it into the given destination [aliases: pack]
5959
recipe Suggest a recipe format
60+
recompile [names..] Byte-recompile `.el' files
6061
refresh Download package archives
6162
reinstall [names..] Reinstall packages
6263
run <type> Run custom tasks

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ by default.
183183

184184
## 🔍 eask compile
185185

186-
Byte-compile files.
186+
Byte-compile `.el` files.
187187

188188
```sh
189189
$ eask compile [FILES..]
@@ -201,6 +201,19 @@ Or compile files that are already specified in your `Eask`-file.
201201
$ eask compile
202202
```
203203

204+
## 🔍 eask recompile
205+
206+
Byte-recompile `.el` files.
207+
208+
```sh
209+
$ eask recompile [FILES..]
210+
```
211+
212+
{{< hint info >}}
213+
💡 Similar to `eask compile`, but it will also remove old `.elc` files before
214+
compiling.
215+
{{< /hint >}}
216+
204217
## 🔍 eask package-directory
205218

206219
Print path to package directory, where all dependencies are installed.

docs/content/Getting-Started/Commands-and-options/_index.zh-tw.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ $ eask package [DESTINATION]
180180

181181
## 🔍 eask compile
182182

183-
字節編譯文件
183+
字節編譯 `.el` 文件
184184

185185
```sh
186186
$ eask compile [FILES..]
@@ -198,6 +198,18 @@ $ eask compile file-1.el file-2.el
198198
$ eask compile
199199
```
200200

201+
## 🔍 eask recompile
202+
203+
重新字節編譯 `.el` 文件。
204+
205+
```sh
206+
$ eask recompile [FILES..]
207+
```
208+
209+
{{< hint info >}}
210+
💡 與 `eask compile` 類似,但它在編譯前會刪除舊的 `.elc` 檔案。
211+
{{< /hint >}}
212+
201213
## 🔍 eask package-directory
202214

203215
打印包目錄的路徑,其中安裝了所有依賴項。

lisp/_prepare.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,8 @@ For arguments MSG and ARGS, please see function `eask-print' for the detials."
16811681
16821682
For arguments MSG and ARGS, please see function `eask--format-paint-kwds' for
16831683
the detials."
1684-
(message (apply #'eask--format-paint-kwds msg args)))
1684+
(apply #'eask-write msg args)
1685+
(eask-princ "\n" t))
16851686

16861687
(defun eask-write (msg &rest args)
16871688
"Like the function `eask-msg' but without newline at the end.

lisp/core/compile.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
;;; core/compile.el --- Byte compile all Emacs Lisp files in the package -*- lexical-binding: t; -*-
1+
;;; core/compile.el --- Byte-compile `.el' files -*- lexical-binding: t; -*-
22

33
;;; Commentary:
44
;;
5-
;; Byte compile all Emacs Lisp files in the package
5+
;; Byte-compile `.el' files,
66
;;
77
;; $ eask compile [names..]
88
;;

lisp/core/recompile.el

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
;;; core/recompile.el --- Byte-recompile `.el' files -*- lexical-binding: t; -*-
2+
3+
;;; Commentary:
4+
;;
5+
;; Byte-recompile `.el' files,
6+
;;
7+
;; $ eask recompile [names..]
8+
;;
9+
;;
10+
;; Positionals:
11+
;;
12+
;; [names..] specify files to byte-recompile
13+
;;
14+
15+
;;; Code:
16+
17+
(let ((dir (file-name-directory (nth 1 (member "-scriptload" command-line-args)))))
18+
(load (expand-file-name "_prepare.el"
19+
(locate-dominating-file dir "_prepare.el"))
20+
nil t))
21+
22+
;;
23+
;;; Core
24+
25+
(eask-start
26+
(eask-call "clean/elc")
27+
(eask-write "")
28+
(eask-call "core/compile"))
29+
30+
;;; core/recompile.el ends here

0 commit comments

Comments
 (0)