diff --git a/lib/cli/entry.js b/lib/cli/entry.js index 962c62a5766da..fb15683f48e1f 100644 --- a/lib/cli/entry.js +++ b/lib/cli/entry.js @@ -26,7 +26,7 @@ module.exports = async (process, validateEngines) => { // It is now safe to log a warning if they are using a version of node that is not going to fail on syntax errors but is still unsupported and untested and might not work reliably. // This is safe to use the logger now which we want since this will show up in the error log too. - if (!satisfies(validateEngines.node, validateEngines.engines)) { + if (!satisfies(validateEngines.node, validateEngines.engines, { includePrerelease: true })) { log.warn('cli', validateEngines.unsupportedMessage) } diff --git a/test/lib/cli/entry.js b/test/lib/cli/entry.js index 369927dace0f2..3c34172970a83 100644 --- a/test/lib/cli/entry.js +++ b/test/lib/cli/entry.js @@ -150,6 +150,31 @@ t.test('unsupported node version', async t => { ) }) +t.test('prerelease node versions', async t => { + for (const [version, supported] of [ + ['v27.0.0-alpha.0.0.0', true], + ['v28.0.0-alpha.0.0.0', true], + ['v27.0.0-rc.0', true], + ['v26.0.0-alpha.0', false], + ['v23.0.0-alpha.0', false], + ]) { + await t.test(version, async t => { + const { cli, logs } = await cliMock(t, { + globals: { + 'process.argv': ['node', 'npm', '--version'], + 'process.version': version, + }, + }) + await cli(process) + if (supported) { + t.strictSame(logs.warn, []) + } else { + t.match(logs.warn[0], `does not support Node.js ${version}.`) + } + }) + } +}) + t.test('non-ascii dash', async t => { const { cli, logs } = await cliMock(t, { globals: {