Skip to content

Commit 2b44398

Browse files
add function to check if process is running in the CI
1 parent d16a36a commit 2b44398

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

v-next/hardhat-utils/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"exports": {
1111
"./bigint": "./dist/src/bigint.js",
1212
"./bytes": "./dist/src/bytes.js",
13+
"./ci": "./dist/src/ci.js",
1314
"./common-errors": "./dist/src/common-errors.js",
1415
"./crypto": "./dist/src/crypto.js",
1516
"./date": "./dist/src/date.js",

v-next/hardhat-utils/src/ci.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Returns 'true' if the current process is running in the GitHub CI environment.
3+
*/
4+
export function isCI() {
5+
return process.env.CI === "true";
6+
}

v-next/hardhat-utils/test/ci.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import assert from "node:assert/strict";
2+
import { describe, it } from "node:test";
3+
4+
import { isCI } from "../src/ci.js";
5+
6+
describe("ci", () => {
7+
it("should be true because the ENV variable CI is true", async function () {
8+
process.env.CI = "true";
9+
assert.equal(isCI(), true);
10+
});
11+
12+
it("should be false because the ENV variable CI is false", async function () {
13+
process.env.CI = "false";
14+
assert.equal(isCI(), false);
15+
});
16+
17+
it("should be false because the ENV variable CI is undefined", async function () {
18+
assert.equal(isCI(), false);
19+
});
20+
});

0 commit comments

Comments
 (0)