Skip to content

Commit 69b5f15

Browse files
committed
code: add new command elsa
1 parent d3ae1e1 commit 69b5f15

2 files changed

Lines changed: 90 additions & 0 deletions

File tree

cmds/lint/elsa.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright (C) 2022 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 = ['elsa [files..]'];
23+
exports.desc = 'run elsa';
24+
exports.builder = {
25+
files: {
26+
description: 'files you want elsa to run on',
27+
requiresArg: false,
28+
type: 'array',
29+
},
30+
};
31+
32+
exports.handler = async (argv) => {
33+
await UTIL.e_call(argv, 'lint/elsa', argv.files);
34+
};

lisp/lint/elsa.el

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
;;; elsa.el --- Run elsa -*- lexical-binding: t; -*-
2+
3+
;;; Commentary:
4+
;;
5+
;; Commmand use to run `elsa' for all files
6+
;;
7+
;; $ eask elsa
8+
;;
9+
;;
10+
;; Initialization options:
11+
;;
12+
;; [files..] files you want elint to run on
13+
;;
14+
15+
;;; Code:
16+
17+
(load (expand-file-name
18+
"../_prepare.el"
19+
(file-name-directory (nth 1 (member "-scriptload" command-line-args))))
20+
nil t)
21+
22+
(defconst eask--elsa-version nil
23+
"Elsa version.")
24+
25+
(defun eask--elsa-process-file (filename)
26+
"Process FILENAME."
27+
(let* ((filename (expand-file-name filename))
28+
(file (eask-root-del filename))
29+
errors)
30+
(eask-msg "")
31+
(eask-msg "`%s` with elsa (%s)" (ansi-green file) eask--elsa-version)
32+
(eask-with-verbosity 'debug
33+
(setq errors (oref (elsa-process-file filename) errors)))
34+
(if errors
35+
(--each (reverse errors)
36+
(let ((line (string-trim (concat file ":" (elsa-message-format it)))))
37+
(cond ((string-match-p "[: ][Ee]rror:" line) (eask-error line))
38+
((string-match-p "[: ][Ww]arning:" line) (eask-warn line))
39+
(t (eask-log line)))))
40+
(eask-msg "No issues found"))))
41+
42+
(eask-start
43+
(eask-with-archives "melpa"
44+
(eask-package-install 'elsa))
45+
(setq eask--elsa-version (eask-package--version-string 'elsa))
46+
(require 'elsa)
47+
(if-let ((files (eask-args-or-package-el-files)))
48+
(progn
49+
(mapcar #'eask--elsa-process-file files)
50+
(eask-info "(Total of %s files linted)" (length files)))
51+
(eask-info "(No files have been linted)")
52+
(if (eask-args)
53+
(eask--print-no-matching-files)
54+
(eask-help 'elsa))))
55+
56+
;;; elsa.el ends here

0 commit comments

Comments
 (0)