@@ -1432,7 +1432,14 @@ This uses function `locate-dominating-file' to look up directory tree."
14321432 (ignore-errors (make-directory package-user-dir t ))
14331433 (eask--silent (eask-setup-paths))
14341434 (eask-with-verbosity 'debug (eask--load-config))
1435- (eask--with-hooks ,@body ))))))))))
1435+ (eask--with-hooks ,@body ))))))
1436+ ; ; Report exit stats if any.
1437+ (eask--resolve-exit-status)))))
1438+
1439+ (defun eask--resolve-exit-status ()
1440+ " Resolve current exit status."
1441+ (when (memq 'error (eask--error-status))
1442+ (eask--exit 'failure )))
14361443
14371444; ;
14381445; ;; Eask file
@@ -1988,35 +1995,63 @@ Argument ARGS are direct arguments for functions `eask-error' or `eask-warn'."
19881995 (declare (indent 0 ) (debug t ))
19891996 `(eask-ignore-errors (eask--silent-error ,@body )))
19901997
1991- (defun eask--trigger-error ()
1992- " Trigger error event."
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+
2013+ (defun eask--trigger-error (args )
2014+ " Trigger error event.
2015+
2016+ The argument ARGS is passed from the function `eask--error' ."
2017+ (cond ((< emacs-major-version 28 )
2018+ ; ; Handle https://github.com/emacs-eask/cli/issues/11.
2019+ (unless (string-prefix-p " Can't find library " (car args))
2020+ (setq eask--has-error-p t )))
2021+ (t
2022+ (setq eask--has-error-p t ))) ; Just a record.
2023+
19932024 (when (and (not eask--ignore-error-p)
1994- (not (eask-checker-p))) ; Ignore when checking Eask-file.
1995- (if (eask-allow-error-p) ; Trigger error at the right time.
1996- (add-hook 'eask-after-command-hook #'eask--exit )
1997- (eask--exit))))
2025+ (not (eask-allow-error-p))
2026+ ; ; Ignore when checking Eask-file.
2027+ (not (eask-checker-p)))
2028+ ; ; Stop immediately.
2029+ (eask--exit 'failure )))
19982030
19992031(defun eask--error (fnc &rest args )
20002032 " On error.
20012033
20022034Arguments FNC and ARGS are used for advice `:around' ."
2003- (setq eask--has-error-p t ) ; Just a record.
20042035 (let ((msg (eask--ansi 'error (apply #'format-message args))))
20052036 (unless eask-inhibit-error-message
20062037 (eask--unsilent (eask-msg " %s" msg)))
20072038 (run-hook-with-args 'eask-on-error-hook 'error msg)
2008- (eask--trigger-error))
2039+ (eask--trigger-error args ))
20092040 (when debug-on-error (apply fnc args)))
20102041
2042+ (defun eask--trigger-warn ()
2043+ " Trigger warning event."
2044+ (setq eask--has-warn-p t )) ; Just a record.
2045+
20112046(defun eask--warn (fnc &rest args )
20122047 " On warn.
20132048
20142049Arguments FNC and ARGS are used for advice `:around' ."
2015- (setq eask--has-warn-p t ) ; Just a record.
20162050 (let ((msg (eask--ansi 'warn (apply #'format-message args))))
20172051 (unless eask-inhibit-error-message
20182052 (eask--unsilent (eask-msg " %s" msg)))
2019- (run-hook-with-args 'eask-on-warning-hook 'warn msg))
2053+ (run-hook-with-args 'eask-on-warning-hook 'warn msg)
2054+ (eask--trigger-warn))
20202055 (eask--silent (apply fnc args)))
20212056
20222057; ; Don't pollute outer exection.
0 commit comments