From f93eaef13b963d3e331b2e5ead653d8af3f7f77e Mon Sep 17 00:00:00 2001 From: Adrien Foulon <6115458+Tofandel@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:34:00 +0100 Subject: [PATCH] Cache family --- lib/current-env.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/current-env.js b/lib/current-env.js index 92134c3..9f3b3d9 100644 --- a/lib/current-env.js +++ b/lib/current-env.js @@ -14,21 +14,22 @@ function cpu () { } let family -if (os() === 'linux') { - const originalExclude = process.report.excludeNetwork - process.report.excludeNetwork = true - const report = process.report.getReport() - process.report.excludeNetwork = originalExclude - if (report.header?.glibcVersionRuntime) { - family = 'glibc' - } else if (Array.isArray(report.sharedObjects) && report.sharedObjects.some(isMusl)) { - family = 'musl' - } -} function libc (osName) { if (osName !== 'linux') { return undefined } + + if (!family) { + const originalExclude = process.report.excludeNetwork + process.report.excludeNetwork = true + const report = process.report.getReport() + process.report.excludeNetwork = originalExclude + if (report.header?.glibcVersionRuntime) { + family = 'glibc' + } else if (Array.isArray(report.sharedObjects) && report.sharedObjects.some(isMusl)) { + family = 'musl' + } + } return family }