Created
January 30, 2025 16:11
-
-
Save bengl/41acfeb8ac572e5761c8493673f13180 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const [MAJOR, MINOR] = process.versions.node.split('.').map(Number) | |
let testCommand = 'node --test' | |
if (MAJOR >= 22 || (MAJOR === 20 && MINOR >= 1) || (MAJOR === 18 && MINOR >= 17)) { | |
testCommand = 'node --experimental-test-coverage --test' | |
} else if (MAJOR >= 20 || (MAJOR === 18 && MINOR >= 1)) { | |
testCommand = 'node --test' | |
} else if (MAJOR >= 18) { | |
testCommand = 'node_modules/.bin/node--test' | |
} else { | |
console.error('Node.js version 18 or higher is required.') | |
process.exit(1) | |
} | |
const { spawn } = require('child_process') | |
spawn(testCommand, { shell: true, stdio: 'inherit' }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment