Skip to content

Commit e5ddc4a

Browse files
kraenhansenclaudelegendecas
authored
chore: extract napiVersion into its own harness module (#57)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Chengzhong Wu <cwu631@bloomberg.net>
1 parent 4188361 commit e5ddc4a

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

implementors/node/features.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ globalThis.experimentalFeatures = {
88
postFinalizer: true,
99
};
1010

11-
globalThis.napiVersion = Number(process.versions.napi);
12-
1311
globalThis.skipTest = () => {
1412
process.exit(0);
1513
};

implementors/node/napi-version.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
globalThis.napiVersion = Number(process.versions.napi);

implementors/node/tests.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ const MUST_CALL_MODULE_PATH = path.join(
4040
"node",
4141
"must-call.js"
4242
);
43+
const NAPI_VERSION_MODULE_PATH = path.join(
44+
ROOT_PATH,
45+
"implementors",
46+
"node",
47+
"napi-version.js"
48+
);
4349

4450
export function listDirectoryEntries(dir: string) {
4551
const entries = fs.readdirSync(dir, { withFileTypes: true });
@@ -80,6 +86,8 @@ export function runFileInSubprocess(
8086
"file://" + GC_MODULE_PATH,
8187
"--import",
8288
"file://" + MUST_CALL_MODULE_PATH,
89+
"--import",
90+
"file://" + NAPI_VERSION_MODULE_PATH,
8391
filePath,
8492
],
8593
{ cwd }

tests/harness/napi-version.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
3+
// napiVersion is a positive integer
4+
if (typeof napiVersion !== 'number' || napiVersion < 1 || !Number.isInteger(napiVersion)) {
5+
throw new Error('Expected a global napiVersion that is a positive integer');
6+
}

0 commit comments

Comments
 (0)