Skip to content

Commit 1cfac4f

Browse files
committed
refactor: ordering
1 parent 2dc8452 commit 1cfac4f

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

lisp/_prepare.el

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,25 +1434,10 @@ This uses function `locate-dominating-file' to look up directory tree."
14341434
(eask-with-verbosity 'debug (eask--load-config))
14351435
(eask--with-hooks ,@body))))))
14361436
;; Report exit stats if any.
1437-
(eask--handle-exit-status)))))
1437+
(eask--resolve-exit-status)))))
14381438

1439-
(defun eask--error-status ()
1440-
"Return error status."
1441-
(let ((result))
1442-
;; Error.
1443-
(when eask--has-error-p
1444-
(push 'error result))
1445-
;; Warning.
1446-
(when eask--has-warn-p
1447-
(push (if (eask-strict-p)
1448-
'error
1449-
'warn)
1450-
result))
1451-
;; No repeat.
1452-
(delete-dups result)))
1453-
1454-
(defun eask--handle-exit-status ()
1455-
"Return non-nil if we should report error for exit status."
1439+
(defun eask--resolve-exit-status ()
1440+
"Resolve current exit status."
14561441
(when (memq 'error (eask--error-status))
14571442
(eask--exit 'failure)))
14581443

@@ -2010,8 +1995,30 @@ Argument ARGS are direct arguments for functions `eask-error' or `eask-warn'."
20101995
(declare (indent 0) (debug t))
20111996
`(eask-ignore-errors (eask--silent-error ,@body)))
20121997

1998+
(defun eask--error-status ()
1999+
"Return error status."
2000+
(let ((result))
2001+
;; Error.
2002+
(when eask--has-error-p
2003+
(push 'error result))
2004+
;; Warning.
2005+
(when eask--has-warn-p
2006+
(push (if (eask-strict-p)
2007+
'error
2008+
'warn)
2009+
result))
2010+
;; No repeat.
2011+
(delete-dups result)))
2012+
20132013
(defun eask--trigger-error ()
20142014
"Trigger error event."
2015+
(cond ((< emacs-major-version 28)
2016+
;; Handle https://github.com/emacs-eask/cli/issues/11.
2017+
(unless (string-prefix-p "Can't find library " (car args))
2018+
(setq eask--has-error-p t)))
2019+
(t
2020+
(setq eask--has-error-p t))) ; Just a record.
2021+
20152022
(when (and (not eask--ignore-error-p)
20162023
(not (eask-allow-error-p))
20172024
;; Ignore when checking Eask-file.
@@ -2023,29 +2030,26 @@ Argument ARGS are direct arguments for functions `eask-error' or `eask-warn'."
20232030
"On error.
20242031
20252032
Arguments FNC and ARGS are used for advice `:around'."
2026-
;; Handle https://github.com/emacs-eask/cli/issues/11.
2027-
(cond ((< emacs-major-version 28)
2028-
(unless (string-prefix-p "Can't find library " (car args))
2029-
(setq eask--has-error-p t)))
2030-
(t
2031-
;; Just a record.
2032-
(setq eask--has-error-p t)))
20332033
(let ((msg (eask--ansi 'error (apply #'format-message args))))
20342034
(unless eask-inhibit-error-message
20352035
(eask--unsilent (eask-msg "%s" msg)))
20362036
(run-hook-with-args 'eask-on-error-hook 'error msg)
20372037
(eask--trigger-error))
20382038
(when debug-on-error (apply fnc args)))
20392039

2040+
(defun eask--trigger-warn ()
2041+
"Trigger warning event."
2042+
(setq eask--has-warn-p t)) ; Just a record.
2043+
20402044
(defun eask--warn (fnc &rest args)
20412045
"On warn.
20422046
20432047
Arguments FNC and ARGS are used for advice `:around'."
2044-
(setq eask--has-warn-p t) ; Just a record.
20452048
(let ((msg (eask--ansi 'warn (apply #'format-message args))))
20462049
(unless eask-inhibit-error-message
20472050
(eask--unsilent (eask-msg "%s" msg)))
2048-
(run-hook-with-args 'eask-on-warning-hook 'warn msg))
2051+
(run-hook-with-args 'eask-on-warning-hook 'warn msg)
2052+
(eask--trigger-warn))
20492053
(eask--silent (apply fnc args)))
20502054

20512055
;; Don't pollute outer exection.

0 commit comments

Comments
 (0)