Skip to content

Commit 1024c36

Browse files
committed
feat: define exit code in js level
1 parent 09cf227 commit 1024c36

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

src/env.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,14 @@ process.env.EMACS = EASK_EMACS; // Set back the value.
3333
global.TITLE_CMD_OPTION = 'Command Options:';
3434
global.TITLE_PROXY_OPTION = 'Proxy Options:';
3535

36+
/* Exit Code
37+
*
38+
* This must match with the variable `eask--exit-code` in
39+
* the file `lisp/_prepare.el`.
40+
*/
41+
global.EXIT_SUCCESS = 0;
42+
global.EXIT_FAILURE = 1;
43+
global.EXIT_MISUSE = 2;
44+
3645
/* CI */
3746
global.GITHUB_ACTIONS = (process.env.GITHUB_WORKSPACE !== undefined);

src/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ async function e_call(argv, script, ...args) {
230230
}
231231

232232
if (!_check_argv(argv)) {
233-
process.exit(1);
233+
process.exit(EXIT_FAILURE);
234234
return;
235235
}
236236

test/jest/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Jest Testing
2+
3+
See the full documentation in https://emacs-eask.github.io/Contributing/Developing-Eask/#-testing.

test/jest/helpers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ const exec = util.promisify(require("node:child_process").exec);
33
const fs = require("node:fs/promises");
44
const path = require("node:path");
55

6+
// Load the environment.
7+
const env = require('../../src/env');
8+
69
/*
710
* This file uses JsDoc syntax.
811
* Documentation for type helpers like @param: https://jsdoc.app/tags-type

test/jest/options.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("options", () => {
2525

2626
it("should error if the number is omitted before the next option", async () => {
2727
await expect(ctx.runEask("info -v --no-color")).rejects.toMatchObject({
28-
code: 1,
28+
code: EXIT_FAILURE,
2929
});
3030
});
3131
});

0 commit comments

Comments
 (0)