Skip to content

Commit

Permalink
feat(cmds): Add recompile command
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jun 7, 2024
1 parent af843f5 commit e1eb0b5
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmds/core/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"use strict";

exports.command = ['compile [names..]'];
exports.desc = 'Byte compile all Emacs Lisp files in the package';
exports.desc = "Byte-compile `.el' files";
exports.builder = yargs => yargs
.positional(
'[names..]', {
Expand Down
40 changes: 40 additions & 0 deletions cmds/core/recompile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (C) 2022-2024 the Eask authors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

"use strict";

exports.command = ['recompile [names..]'];
exports.desc = "Byte-recompile `.el' files";
exports.builder = yargs => yargs
.positional(
'[names..]', {
description: 'specify files to byte-compile',
type: 'array',
})
.options({
'clean': {
description: 'clean byte-recompile files individually',
type: 'boolean',
group: TITLE_CMD_OPTION,
},
});

exports.handler = async (argv) => {
await UTIL.e_call(argv, 'core/recompile'
, argv.names
, UTIL.def_flag(argv.clean, '--clean'));
};
5 changes: 3 additions & 2 deletions docs/content/Getting-Started/Basic-Usage/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ Commands:
analyze [files..] Run Eask checker
archives List out all package archives [aliases: sources]
clean <type> Delete various files produced during building
compile [names..] Byte compile all Emacs Lisp files in the package
compile [names..] Byte-compile `.el' files
create <type> Create a new elisp project
docker <version> [args..] Launch specified Emacs version in a Docker container
docs Build documentation [aliases: doc]
docs [names..] Build documentation [aliases: doc]
emacs [args..] Execute emacs with the appropriate environment
eval [form] Evaluate lisp form with a proper PATH
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
Expand All @@ -60,6 +60,7 @@ Commands:
package-directory Print path to package directory
package [destination] Build a package artifact, and put it into the given destination [aliases: pack]
recipe Suggest a recipe format
recompile [names..] Byte-recompile `.el' files
refresh Download package archives
reinstall [names..] Reinstall packages
run <type> Run custom tasks
Expand Down
5 changes: 3 additions & 2 deletions docs/content/Getting-Started/Basic-Usage/_index.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ Commands:
analyze [files..] Run Eask checker
archives List out all package archives [aliases: sources]
clean <type> Delete various files produced during building
compile [names..] Byte compile all Emacs Lisp files in the package
compile [names..] Byte-compile `.el' files
create <type> Create a new elisp project
docker <version> [args..] Launch specified Emacs version in a Docker container
docs Build documentation [aliases: doc]
docs [names..] Build documentation [aliases: doc]
emacs [args..] Execute emacs with the appropriate environment
eval [form] Evaluate lisp form with a proper PATH
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
Expand All @@ -57,6 +57,7 @@ Commands:
package-directory Print path to package directory
package [destination] Build a package artifact, and put it into the given destination [aliases: pack]
recipe Suggest a recipe format
recompile [names..] Byte-recompile `.el' files
refresh Download package archives
reinstall [names..] Reinstall packages
run <type> Run custom tasks
Expand Down
15 changes: 14 additions & 1 deletion docs/content/Getting-Started/Commands-and-options/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ by default.

## 🔍 eask compile

Byte-compile files.
Byte-compile `.el` files.

```sh
$ eask compile [FILES..]
Expand All @@ -201,6 +201,19 @@ Or compile files that are already specified in your `Eask`-file.
$ eask compile
```

## 🔍 eask recompile

Byte-recompile `.el` files.

```sh
$ eask recompile [FILES..]
```

{{< hint info >}}
💡 Similar to `eask compile`, but it will also remove old `.elc` files before
compiling.
{{< /hint >}}

## 🔍 eask package-directory

Print path to package directory, where all dependencies are installed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ $ eask package [DESTINATION]

## 🔍 eask compile

字節編譯文件
字節編譯 `.el` 文件

```sh
$ eask compile [FILES..]
Expand All @@ -198,6 +198,18 @@ $ eask compile file-1.el file-2.el
$ eask compile
```

## 🔍 eask recompile

重新字節編譯 `.el` 文件。

```sh
$ eask recompile [FILES..]
```

{{< hint info >}}
💡 與 `eask compile` 類似,但它在編譯前會刪除舊的 `.elc` 檔案。
{{< /hint >}}

## 🔍 eask package-directory

打印包目錄的路徑,其中安裝了所有依賴項。
Expand Down
4 changes: 2 additions & 2 deletions lisp/core/compile.el
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
;;; core/compile.el --- Byte compile all Emacs Lisp files in the package -*- lexical-binding: t; -*-
;;; core/compile.el --- Byte-compile `.el' files -*- lexical-binding: t; -*-

;;; Commentary:
;;
;; Byte compile all Emacs Lisp files in the package
;; Byte-compile `.el' files,
;;
;; $ eask compile [names..]
;;
Expand Down
30 changes: 30 additions & 0 deletions lisp/core/recompile.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
;;; core/recompile.el --- Byte-recompile `.el' files -*- lexical-binding: t; -*-

;;; Commentary:
;;
;; Byte-recompile `.el' files,
;;
;; $ eask recompile [names..]
;;
;;
;; Positionals:
;;
;; [names..] specify files to byte-recompile
;;

;;; Code:

(let ((dir (file-name-directory (nth 1 (member "-scriptload" command-line-args)))))
(load (expand-file-name "_prepare.el"
(locate-dominating-file dir "_prepare.el"))
nil t))

;;
;;; Core

(eask-start
(eask-call "clean/elc")
(eask-println "")
(eask-call "core/compile"))

;;; core/recompile.el ends here
1 change: 1 addition & 0 deletions test/commands/local/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ eask package
# Development
eask compile
eask compile --clean
eask recompile
eask recipe
eask keywords
eask run script
Expand Down

0 comments on commit e1eb0b5

Please sign in to comment.