diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eeb650c..48e0d212 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how * Add command to clean log files (#97) * Add command to clean autoloads file (#98) * Add command to clean pkg-file (#99) +* feat: Add option `-o`/`--output` to output log for Eask checker (#100) ## 0.7.x > Released Sep 08, 2022 diff --git a/cmds/checker/check-eask.js b/cmds/checker/check-eask.js index 3e96efa8..97f23de8 100644 --- a/cmds/checker/check-eask.js +++ b/cmds/checker/check-eask.js @@ -27,6 +27,11 @@ exports.builder = { requiresArg: false, type: 'array', }, + output: { + description: 'Output result to a file', + alias: 'o', + type: 'string', + }, json: { description: 'Output lint result in JSON format', type: 'boolean', diff --git a/lisp/_prepare.el b/lisp/_prepare.el index 74f45e7f..80f05275 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -444,6 +444,7 @@ the `eask-start' execution.") (defun eask-json-p () (eask--flag "--json")) ; --json ;;; String (with arguments) +(defun eask-output () (eask--flag-value "-o")) ; --o, --output (defun eask-proxy () (eask--flag-value "--proxy")) ; --proxy (defun eask-http-proxy () (eask--flag-value "--http-proxy")) ; --http-proxy (defun eask-https-proxy () (eask--flag-value "--https-proxy")) ; --https-proxy @@ -504,15 +505,16 @@ other scripts internally. See function `eask-call'.") "--timestamps" "--log-level" "--log-file" "--elapsed-time" - "--no-color")) + "--no-color" + "--json")) "List of boolean type options.") (defconst eask--option-args (eask--form-options - '("--proxy" "--http-proxy" "--https-proxy" "--no-proxy" + '("-o" + "--proxy" "--http-proxy" "--https-proxy" "--no-proxy" "--verbose" "--silent" - "--depth" "--dest" - "--json")) + "--depth" "--dest")) "List of arguments (number/string) type options.") (defconst eask--command-list diff --git a/lisp/checker/check-eask.el b/lisp/checker/check-eask.el index d388ad2e..cf1bce98 100644 --- a/lisp/checker/check-eask.el +++ b/lisp/checker/check-eask.el @@ -115,7 +115,8 @@ default-directory)) (files (or (eask-expand-file-specs (eask-args)) (eask-expand-file-specs '("Eask*" "**/Eask*")))) - checked-files) + checked-files + content) ;; Linting (dolist (file files) (eask--save-eask-file-state @@ -128,15 +129,25 @@ (eask-msg "") (cond ((and (eask-json-p) ; JSON format (or eask--checker-warnings eask--checker-errors)) - (eask-msg - (eask--pretty-json (json-encode - `((warnings . ,eask--checker-warnings) - (errors . ,eask--checker-errors)))))) + (setq content + (eask--pretty-json (json-encode + `((warnings . ,eask--checker-warnings) + (errors . ,eask--checker-errors))))) + (eask-msg content)) (eask--checker-log ; Plain text + (setq content + (with-temp-buffer + (dolist (msg (reverse eask--checker-log)) + (insert msg "\n")) + (buffer-string))) (mapc #'eask-msg (reverse eask--checker-log))) (t (eask-info "(Checked %s file%s)" (length checked-files) - (eask--sinr checked-files "" "s"))))) + (eask--sinr checked-files "" "s")))) + + ;; Output file + (when (and content (eask-output)) + (write-region content nil (eask-output)))) ;;; checker/check-eask.el ends here diff --git a/src/util.js b/src/util.js index feb4bfdf..bde053a6 100644 --- a/src/util.js +++ b/src/util.js @@ -92,6 +92,7 @@ function _global_options(argv) { /* Number type */ flags.push(def_flag(argv.verbose, '--verbose', argv.verbose)); /* String type */ + flags.push(def_flag(argv.output, '-o', argv.output)); flags.push(def_flag(argv.proxy, '--proxy', argv.proxy)); flags.push(def_flag(argv['http-proxy'], '--http-proxy', argv['http-proxy'])); flags.push(def_flag(argv['https-proxy'], '--https-proxy', argv['https-proxy']));