Skip to content

Commit

Permalink
Test ESM imports on Node >=v18.19
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners-nr committed Dec 11, 2023
1 parent 437823d commit 25a34ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions test/get-esm-exports/v18.19-get-esm-exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// v18.19.0 backported ESM hook execution to a separate thread,
// thus being equivalent to >=v20.
require('./v20-get-esm-exports')
15 changes: 10 additions & 5 deletions test/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ const args = [
...process.argv.slice(2)
]

const [processMajor] = process.versions.node.split('.').map(Number)
const [processMajor, processMinor] = process.versions.node.split('.').map(Number)

const match = filename.match(/v([0-9]+)/)
const match = filename.match(/v([0-9]+)(?:\.([0-9]+))?/)

const versionRequirement = match ? match[1] : 0;
const majorRequirement = match ? match[1] : 0;
const minorRequirement = match && match?.[2];

if (processMajor < versionRequirement) {
console.log(`skipping ${filename} as this is Node.js v${processMajor} and test wants v${versionRequirement}`);
if (processMajor < majorRequirement && minorRequirement === undefined) {
console.log(`skipping ${filename} as this is Node.js v${processMajor} and test wants v${majorRequirement}`);
process.exit(0);
}
if (processMajor < majorRequirement && processMinor < minorRequirement) {
console.log(`skipping ${filename} as this is Node.js v${processMajor}.${processMinor} and test wants >=v${majorRequirement}.${minorRequirement}`);
process.exit(0);
}

Expand Down

0 comments on commit 25a34ce

Please sign in to comment.