Skip to content

Commit 7468cf1

Browse files
committed
fix: Handle Can't find library error
1 parent 7ff3fae commit 7468cf1

File tree

5 files changed

+45
-46
lines changed

5 files changed

+45
-46
lines changed

lisp/_prepare.el

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,29 @@ 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--handle-exit-status)))))
1438+
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."
1456+
(when (memq 'error (eask--error-status))
1457+
(eask--exit 'failure)))
14361458

14371459
;;
14381460
;;; Eask file
@@ -1991,16 +2013,23 @@ Argument ARGS are direct arguments for functions `eask-error' or `eask-warn'."
19912013
(defun eask--trigger-error ()
19922014
"Trigger error event."
19932015
(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))))
2016+
(not (eask-allow-error-p))
2017+
;; Ignore when checking Eask-file.
2018+
(not (eask-checker-p)))
2019+
;; Stop immediately.
2020+
(eask--exit 'failure)))
19982021

19992022
(defun eask--error (fnc &rest args)
20002023
"On error.
20012024
20022025
Arguments FNC and ARGS are used for advice `:around'."
2003-
(setq eask--has-error-p t) ; Just a record.
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)))
20042033
(let ((msg (eask--ansi 'error (apply #'format-message args))))
20052034
(unless eask-inhibit-error-message
20062035
(eask--unsilent (eask-msg "%s" msg)))

test/jest/exec.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
const cmp = require('semver-compare');
21
const { emacsVersion, TestContext } = require("./helpers");
32

43
describe("exec", () => {
54
const ctx = new TestContext("./test/jest/exec");
65

76
beforeAll(async () => {
87
await ctx.runEask(
9-
"install-deps", { timeout: 40000 },
10-
// See https://github.com/emacs-eask/cli/issues/11.
11-
cmp(await emacsVersion(), "28.1") == -1);
8+
"install-deps", { timeout: 40000 });
129
});
1310

1411
afterAll(() => ctx.cleanUp());

test/jest/install.test.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ describe("install and uninstall", () => {
1414

1515
it("installs project package", async () => {
1616
// creates dist/<pkg>.tar
17-
await ctx.runEask("package", { timeout: 40000 },
18-
// See https://github.com/emacs-eask/cli/issues/11.
19-
cmp(await emacsVersion(), "28.1") == -1);
17+
await ctx.runEask("package");
2018
// installs dependencies and generated package
2119
await ctx.runEask("install");
2220
const { stderr } = await ctx.runEask("list");
@@ -41,18 +39,13 @@ describe("install and uninstall", () => {
4139
});
4240

4341
it("uninstalls project package", async () => {
44-
await ctx.runEask("uninstall", { timeout: 40000 },
45-
// See https://github.com/emacs-eask/cli/issues/11.
46-
cmp(await emacsVersion(), "28.1") == -1);
42+
await ctx.runEask("uninstall");
4743
const { stderr } = await ctx.runEask("list");
4844
expect(stderr).not.toMatch(packageName);
4945
});
5046

5147
it("installs dependencies", async () => {
52-
const { stderr } = await ctx.runEask(
53-
"install-deps", { timeout: 40000 },
54-
// See https://github.com/emacs-eask/cli/issues/11.
55-
cmp(await emacsVersion(), "28.1") == -1);
48+
const { stderr } = await ctx.runEask("install-deps");
5649
expect(stderr).not.toMatch(packageName);
5750
});
5851

test/jest/local.test.js

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// Notice, below we clone a random package (repo) that uses Eask as the
55
// dependencies management tool.
66

7-
const cmp = require('semver-compare');
87
const { emacsVersion, TestContext } = require("./helpers");
98

109
describe("local", () => {
@@ -15,10 +14,7 @@ describe("local", () => {
1514
// this is because of recipe dependencies triggering
1615
// "temporary archives" build.
1716
beforeAll(async () => {
18-
await ctx.runEask(
19-
"install-deps", { timeout: 40000 },
20-
// See https://github.com/emacs-eask/cli/issues/11.
21-
cmp(await emacsVersion(), "28.1") == -1);
17+
await ctx.runEask("install-deps", { timeout: 40000 });
2218
});
2319

2420
afterAll(() => ctx.cleanUp());
@@ -84,10 +80,7 @@ describe("local", () => {
8480

8581
describe("Development", () => {
8682
beforeAll(async () => {
87-
await ctx.runEask(
88-
"install-deps", { timeout: 40000 },
89-
// See https://github.com/emacs-eask/cli/issues/11.
90-
cmp(await emacsVersion(), "28.1") == -1)
83+
await ctx.runEask("install-deps", { timeout: 40000 });
9184
});
9285

9386
// this requires install-deps
@@ -123,9 +116,7 @@ describe("local", () => {
123116

124117
describe("Execution", () => {
125118
beforeAll(async () => {
126-
await ctx.runEask("install-deps", { timeout: 40000 },
127-
// See https://github.com/emacs-eask/cli/issues/11.
128-
cmp(await emacsVersion(), "28.1") == -1)
119+
await ctx.runEask("install-deps", { timeout: 40000 });
129120
});
130121

131122
test("eval", async () => {
@@ -212,15 +203,14 @@ describe("local", () => {
212203
describe("Linting", () => {
213204
// some lint commands may fail if packages are missing
214205
beforeAll(async () => {
215-
await ctx.runEask("install-deps", { timeout: 40000 },
216-
// See https://github.com/emacs-eask/cli/issues/11.
217-
cmp(await emacsVersion(), "28.1") == -1)
206+
await ctx.runEask("install-deps", { timeout: 40000 });
218207
});
219208

220209
it.each([
221210
"lint checkdoc",
222211
"lint declare",
223212
"lint elint",
213+
"lint elisp-lint",
224214
"lint indent",
225215
"lint keywords",
226216
"lint license",
@@ -234,12 +224,6 @@ describe("local", () => {
234224
await ctx.runEask("lint elsa");
235225
});
236226

237-
it("lint elint", async () => {
238-
await ctx.runEask("lint elisp-lint", { },
239-
// See https://github.com/emacs-eask/cli/issues/11.
240-
cmp(await emacsVersion(), "28.1") == -1);
241-
});
242-
243227
it("lint regexps", async () => {
244228
if (cmp(await emacsVersion(), "27.1") == 1) {
245229
await ctx.runEask("lint regexps");

test/jest/outdated-upgrade.test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
const cmp = require('semver-compare');
21
const { emacsVersion, TestContext } = require("./helpers");
32

43
describe("outdated and upgrade", () => {
54
const ctx = new TestContext("./test/jest/outdated-upgrade");
65

76
beforeAll(async () => {
8-
await ctx.runEask(
9-
"install-deps", { timeout: 40000 },
10-
// See https://github.com/emacs-eask/cli/issues/11.
11-
cmp(await emacsVersion(), "28.1") == -1);
7+
await ctx.runEask("install-deps", { timeout: 40000 });
128
await ctx.runEask("load make-outdate.el");
139
});
1410

0 commit comments

Comments
 (0)