Skip to content

Commit 570f79d

Browse files
committed
fix: do not call process.exit; set process.exitCode instead
1 parent 9cae5e7 commit 570f79d

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

packages/hardhat-solhint/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ task("check", async (_, { run }, runSuper) => {
136136
);
137137

138138
if (errorsCount > 0) {
139-
process.exit(1);
139+
process.exitCode = 1;
140+
return;
140141
}
141142
});

packages/hardhat-solhint/test/tests.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,24 @@ describe("Solhint plugin", function () {
3636
);
3737
});
3838

39-
it("should run the check task and exit", async function () {
39+
it("should run the check task and set the exit code to 1", async function () {
4040
const consoleLogStub = sinon.stub(console, "log");
41-
const processExitStub = sinon.stub(process, "exit");
4241
await this.env.run("check");
4342
assert.isTrue(consoleLogStub.calledOnce);
44-
assert.isTrue(processExitStub.calledOnceWith(1));
43+
assert.strictEqual(process.exitCode, 1);
4544
consoleLogStub.restore();
46-
processExitStub.restore();
45+
process.exitCode = undefined;
4746
});
4847
});
4948

5049
describe("Project with no errors", function () {
5150
useEnvironment("no-errors-project");
5251

53-
it("should run the check task and not exit", async function () {
52+
it("should run the check task and not set the exit code", async function () {
5453
const consoleLogStub = sinon.stub(console, "log");
55-
const processExitStub = sinon.stub(process, "exit");
5654
await this.env.run("check");
5755
assert.isTrue(consoleLogStub.calledOnce);
58-
assert.isTrue(processExitStub.notCalled);
59-
consoleLogStub.restore();
60-
processExitStub.restore();
56+
assert.strictEqual(process.exitCode, undefined);
6157
});
6258
});
6359

0 commit comments

Comments
 (0)