From 90abd927c9521024970c5e10bc1585ba1f68c530 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Sun, 23 Apr 2023 11:54:41 +0100 Subject: [PATCH] Install: coerce libc version to semver (refactor) --- install/libvips.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/install/libvips.js b/install/libvips.js index 493c79672..339f22284 100644 --- a/install/libvips.js +++ b/install/libvips.js @@ -140,17 +140,19 @@ try { throw new Error(`BSD/SunOS systems require manual installation of libvips >= ${minimumLibvipsVersion}`); } // Linux libc version check - const libcFamily = detectLibc.familySync(); const libcVersionRaw = detectLibc.versionSync(); - const libcVersion = semverCoerce(libcVersionRaw).version; - if (libcFamily === detectLibc.GLIBC && libcVersion && minimumGlibcVersionByArch[arch]) { - if (semverLessThan(libcVersion, semverCoerce(minimumGlibcVersionByArch[arch]).version)) { - handleError(new Error(`Use with glibc ${libcVersionRaw} requires manual installation of libvips >= ${minimumLibvipsVersion}`)); + if (libcVersionRaw) { + const libcFamily = detectLibc.familySync(); + const libcVersion = semverCoerce(libcVersionRaw).version; + if (libcFamily === detectLibc.GLIBC && minimumGlibcVersionByArch[arch]) { + if (semverLessThan(libcVersion, semverCoerce(minimumGlibcVersionByArch[arch]).version)) { + handleError(new Error(`Use with glibc ${libcVersionRaw} requires manual installation of libvips >= ${minimumLibvipsVersion}`)); + } } - } - if (libcFamily === detectLibc.MUSL && libcVersion) { - if (semverLessThan(libcVersion, '1.1.24')) { - handleError(new Error(`Use with musl ${libcVersionRaw} requires manual installation of libvips >= ${minimumLibvipsVersion}`)); + if (libcFamily === detectLibc.MUSL) { + if (semverLessThan(libcVersion, '1.1.24')) { + handleError(new Error(`Use with musl ${libcVersionRaw} requires manual installation of libvips >= ${minimumLibvipsVersion}`)); + } } } // Node.js minimum version check