Skip to content

Commit c9d2737

Browse files
authored
feat: Add option --output to output log for Eask checker (#100)
* feat: Add option --output to output log for Eask checker * changelog * Fix function name
1 parent b1f9595 commit c9d2737

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
3333
* Add command to clean log files (#97)
3434
* Add command to clean autoloads file (#98)
3535
* Add command to clean pkg-file (#99)
36+
* feat: Add option `-o`/`--output` to output log for Eask checker (#100)
3637

3738
## 0.7.x
3839
> Released Sep 08, 2022

cmds/checker/check-eask.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ exports.builder = {
2727
requiresArg: false,
2828
type: 'array',
2929
},
30+
output: {
31+
description: 'Output result to a file',
32+
alias: 'o',
33+
type: 'string',
34+
},
3035
json: {
3136
description: 'Output lint result in JSON format',
3237
type: 'boolean',

lisp/_prepare.el

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ the `eask-start' execution.")
444444
(defun eask-json-p () (eask--flag "--json")) ; --json
445445

446446
;;; String (with arguments)
447+
(defun eask-output () (eask--flag-value "-o")) ; --o, --output
447448
(defun eask-proxy () (eask--flag-value "--proxy")) ; --proxy
448449
(defun eask-http-proxy () (eask--flag-value "--http-proxy")) ; --http-proxy
449450
(defun eask-https-proxy () (eask--flag-value "--https-proxy")) ; --https-proxy
@@ -504,15 +505,16 @@ other scripts internally. See function `eask-call'.")
504505
"--timestamps" "--log-level"
505506
"--log-file"
506507
"--elapsed-time"
507-
"--no-color"))
508+
"--no-color"
509+
"--json"))
508510
"List of boolean type options.")
509511

510512
(defconst eask--option-args
511513
(eask--form-options
512-
'("--proxy" "--http-proxy" "--https-proxy" "--no-proxy"
514+
'("-o"
515+
"--proxy" "--http-proxy" "--https-proxy" "--no-proxy"
513516
"--verbose" "--silent"
514-
"--depth" "--dest"
515-
"--json"))
517+
"--depth" "--dest"))
516518
"List of arguments (number/string) type options.")
517519

518520
(defconst eask--command-list

lisp/checker/check-eask.el

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@
115115
default-directory))
116116
(files (or (eask-expand-file-specs (eask-args))
117117
(eask-expand-file-specs '("Eask*" "**/Eask*"))))
118-
checked-files)
118+
checked-files
119+
content)
119120
;; Linting
120121
(dolist (file files)
121122
(eask--save-eask-file-state
@@ -128,15 +129,25 @@
128129
(eask-msg "")
129130
(cond ((and (eask-json-p) ; JSON format
130131
(or eask--checker-warnings eask--checker-errors))
131-
(eask-msg
132-
(eask--pretty-json (json-encode
133-
`((warnings . ,eask--checker-warnings)
134-
(errors . ,eask--checker-errors))))))
132+
(setq content
133+
(eask--pretty-json (json-encode
134+
`((warnings . ,eask--checker-warnings)
135+
(errors . ,eask--checker-errors)))))
136+
(eask-msg content))
135137
(eask--checker-log ; Plain text
138+
(setq content
139+
(with-temp-buffer
140+
(dolist (msg (reverse eask--checker-log))
141+
(insert msg "\n"))
142+
(buffer-string)))
136143
(mapc #'eask-msg (reverse eask--checker-log)))
137144
(t
138145
(eask-info "(Checked %s file%s)"
139146
(length checked-files)
140-
(eask--sinr checked-files "" "s")))))
147+
(eask--sinr checked-files "" "s"))))
148+
149+
;; Output file
150+
(when (and content (eask-output))
151+
(write-region content nil (eask-output))))
141152

142153
;;; checker/check-eask.el ends here

src/util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ function _global_options(argv) {
9292
/* Number type */
9393
flags.push(def_flag(argv.verbose, '--verbose', argv.verbose));
9494
/* String type */
95+
flags.push(def_flag(argv.output, '-o', argv.output));
9596
flags.push(def_flag(argv.proxy, '--proxy', argv.proxy));
9697
flags.push(def_flag(argv['http-proxy'], '--http-proxy', argv['http-proxy']));
9798
flags.push(def_flag(argv['https-proxy'], '--https-proxy', argv['https-proxy']));

0 commit comments

Comments
 (0)