-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathpackage.el
More file actions
92 lines (77 loc) · 2.61 KB
/
package.el
File metadata and controls
92 lines (77 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
;;; lint/package.el --- Lint the package using `package-lint' -*- lexical-binding: t; -*-
;;; Commentary:
;;
;; Command use to lint current Emacs package,
;;
;; $ eask lint package [files..]
;;
;;
;; Positionals:
;;
;; [files..] specify files to do package lint
;;
;;; 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))
;;
;;; Externals
(declare-function package-lint-current-buffer "ext:package-lint.el")
;;
;;; Flags
(advice-add #'eask-allow-error-p :override #'eask-always)
;;
;;; Handle options
(add-hook 'eask-before-command-hook
(lambda ()
(when (and (not (boundp 'package-lint-batch-fail-on-warnings))
(not (eask-strict-p)))
;; TODO: This doesn't work since this variable only controls
;; `package-lint' exit code.
(setq package-lint-batch-fail-on-warnings nil))))
;;
;;; Core
(defconst eask-lint-package--version nil
"`package-lint' version.")
(defun eask-lint-package--file (filename)
"Package lint FILENAME."
(let* ((filename (expand-file-name filename))
(file (eask-root-del filename)))
(eask-msg "")
(eask-msg "`%s` with package-lint (%s)" (ansi-green file) eask-lint-package--version)
(with-current-buffer (find-file filename)
(package-lint-current-buffer)
(kill-current-buffer)))
(eask-print-log-buffer "*Package-Lint*"))
(eask-start
;; Preparation
(eask-archive-install-packages '("gnu" "melpa")
'package-lint)
(setq eask-lint-package--version (eask-package--version-string 'package-lint))
;; Start Linting
(require 'package-lint)
(let* ((patterns (eask-args))
(files (if patterns
(eask-expand-file-specs patterns)
(eask-package-el-files))))
(cond
;; Files found, do the action!
(files
(eask-pkg-init) ; XXX: Avoid not installable error!
(setq package-lint-main-file eask-package-file)
(mapcar #'eask-lint-package--file files)
(eask-msg "")
(eask-info "(Total of %s file%s linted)" (length files)
(eask--sinr files "" "s")))
;; Pattern defined, but no file found!
(patterns
(eask-msg "")
(eask-info "(No files match wildcard: %s)"
(mapconcat #'identity patterns " ")))
;; Default, print help!
(t
(eask-msg "")
(eask-info "(No files have been linted)")
(eask-help "lint/package")))))
;;; lint/package.el ends here