Add runtime check for outdated Node.js version

This commit is contained in:
Lovell Fuller
2024-01-10 13:50:20 +00:00
parent b96389d975
commit 45e8071599
3 changed files with 23 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ const { spawnSync } = require('node:child_process');
const { createHash } = require('node:crypto');
const semverCoerce = require('semver/functions/coerce');
const semverGreaterThanOrEqualTo = require('semver/functions/gte');
const semverSatisfies = require('semver/functions/satisfies');
const detectLibc = require('detect-libc');
const { engines, optionalDependencies } = require('../package.json');
@@ -83,6 +84,15 @@ const buildSharpLibvipsLibDir = () => {
return '';
};
const isUnsupportedNodeRuntime = () => {
/* istanbul ignore next */
if (process.release?.name === 'node' && process.versions) {
if (!semverSatisfies(process.versions.node, engines.node)) {
return { found: process.versions.node, expected: engines.node };
}
}
};
/* istanbul ignore next */
const isEmscripten = () => {
const { CC } = process.env;
@@ -174,6 +184,7 @@ module.exports = {
buildSharpLibvipsIncludeDir,
buildSharpLibvipsCPlusPlusDir,
buildSharpLibvipsLibDir,
isUnsupportedNodeRuntime,
runtimePlatformArch,
log,
yarnLocator,