Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Nov 26, 2024
1 parent 5dffd11 commit e32284a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
36 changes: 32 additions & 4 deletions node_modules/npm-install-checks/lib/current-env.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const process = require('node:process')
const nodeOs = require('node:os')
const fs = require('node:fs')

function isMusl (file) {
return file.includes('libc.musl-') || file.includes('ld-musl-')
Expand All @@ -13,12 +14,23 @@ function cpu () {
return process.arch
}

function libc (osName) {
// this is to make it faster on non linux machines
if (osName !== 'linux') {
const LDD_PATH = '/usr/bin/ldd'
function getFamilyFromFilesystem () {
try {
const content = fs.readFileSync(LDD_PATH, 'utf-8')
if (content.includes('musl')) {
return 'musl'
}
if (content.includes('GNU C Library')) {
return 'glibc'
}
return null
} catch {
return undefined
}
let family
}

function getFamilyFromReport () {
const originalExclude = process.report.excludeNetwork
process.report.excludeNetwork = true
const report = process.report.getReport()
Expand All @@ -27,6 +39,22 @@ function libc (osName) {
family = 'glibc'
} else if (Array.isArray(report.sharedObjects) && report.sharedObjects.some(isMusl)) {
family = 'musl'
} else {
family = null
}
return family
}

let family
function libc (osName) {
if (osName !== 'linux') {
return undefined
}
if (family === undefined) {
family = getFamilyFromFilesystem()
if (family === undefined) {
family = getFamilyFromReport()
}
}
return family
}
Expand Down
6 changes: 3 additions & 3 deletions node_modules/npm-install-checks/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "npm-install-checks",
"version": "7.1.0",
"version": "7.1.1",
"description": "Check the engines and platform fields in package.json",
"main": "lib/index.js",
"dependencies": {
"semver": "^7.1.1"
},
"devDependencies": {
"@npmcli/eslint-config": "^5.0.0",
"@npmcli/template-oss": "4.23.3",
"@npmcli/template-oss": "4.23.4",
"tap": "^16.0.1"
},
"scripts": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"author": "GitHub Inc.",
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.23.3",
"version": "4.23.4",
"publish": "true"
},
"tap": {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"nopt": "^8.0.0",
"normalize-package-data": "^7.0.0",
"npm-audit-report": "^6.0.0",
"npm-install-checks": "^7.1.0",
"npm-install-checks": "^7.1.1",
"npm-package-arg": "^12.0.0",
"npm-pick-manifest": "^10.0.0",
"npm-profile": "^11.0.1",
Expand Down Expand Up @@ -12167,9 +12167,9 @@
}
},
"node_modules/npm-install-checks": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-7.1.0.tgz",
"integrity": "sha512-bkTildVlofeMX7wiOaWk3PlW7YcBXAuEc7TWpOxwUgalG5ZvgT/ms+6OX9zt7iGLv4+VhKbRZhpOfgQJzk1YAw==",
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-7.1.1.tgz",
"integrity": "sha512-u6DCwbow5ynAX5BdiHQ9qvexme4U3qHW3MWe5NqH+NeBm0LbiH6zvGjNNew1fY+AZZUtVHbOPF3j7mJxbUzpXg==",
"inBundle": true,
"license": "BSD-2-Clause",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"nopt": "^8.0.0",
"normalize-package-data": "^7.0.0",
"npm-audit-report": "^6.0.0",
"npm-install-checks": "^7.1.0",
"npm-install-checks": "^7.1.1",
"npm-package-arg": "^12.0.0",
"npm-pick-manifest": "^10.0.0",
"npm-profile": "^11.0.1",
Expand Down

0 comments on commit e32284a

Please sign in to comment.