Skip to content

Commit 61b57d5

Browse files
authored
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
1 parent 4751cb4 commit 61b57d5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/current-env.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ function cpu () {
1313
return process.arch
1414
}
1515

16+
let family
17+
1618
function libc (osName) {
1719
// this is to make it faster on non linux machines
1820
if (osName !== 'linux') {
1921
return undefined
2022
}
21-
let family
23+
if (family) {
24+
return family
25+
}
2226
const originalExclude = process.report.excludeNetwork
2327
process.report.excludeNetwork = true
2428
const report = process.report.getReport()

0 commit comments

Comments
 (0)