From 61b57d577aec4c31cf84d05aa86553cb952c10ba Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 28 Oct 2024 12:41:20 -0400 Subject: [PATCH] fix: cache family when calling libc() We can assume that the same process will return the same report and thus we can cache the resulting family in memory to make it faster for subsequent invocations. https://github.com/npm/cli/blob/780afc50e3a345feb1871a28e33fa48235bc3bd5/workspaces/arborist/lib/arborist/build-ideal-tree.js#L212 --- lib/current-env.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/current-env.js b/lib/current-env.js index 9babde1..cf5e886 100644 --- a/lib/current-env.js +++ b/lib/current-env.js @@ -13,12 +13,16 @@ function cpu () { return process.arch } +let family + function libc (osName) { // this is to make it faster on non linux machines if (osName !== 'linux') { return undefined } - let family + if (family) { + return family + } const originalExclude = process.report.excludeNetwork process.report.excludeNetwork = true const report = process.report.getReport()