Skip to content

Commit

Permalink
fix: handle lld not found (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
yisibl authored Jan 11, 2022
1 parent 4833a80 commit 22e10ee
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 193 deletions.
21 changes: 16 additions & 5 deletions js-binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@ const { platform, arch } = process

let nativeBinding = null
let localFileExisted = false
let isMusl = false
let loadError = null

function isMusl() {
// For Node 10
if (!process.report || typeof process.report.getReport !== 'function') {
try {
return readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
} catch (e) {
return false
}
} else {
const { glibcVersionRuntime } = process.report.getReport().header
return !Boolean(glibcVersionRuntime)
}
}

switch (platform) {
case 'android':
if (arch !== 'arm64') {
Expand Down Expand Up @@ -122,8 +135,7 @@ switch (platform) {
case 'linux':
switch (arch) {
case 'x64':
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
if (isMusl) {
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'resvgjs.linux-x64-musl.node')
)
Expand Down Expand Up @@ -152,8 +164,7 @@ switch (platform) {
}
break
case 'arm64':
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
if (isMusl) {
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'resvgjs.linux-arm64-musl.node')
)
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
"version": "napi version"
},
"devDependencies": {
"@napi-rs/canvas": "^0.1.17",
"@napi-rs/cli": "^2.2.0",
"@napi-rs/canvas": "^0.1.19",
"@napi-rs/cli": "^2.3.0",
"@swc-node/register": "^1.4.2",
"@types/node": "^17.0.1",
"@types/sharp": "^0.29.5",
Expand All @@ -75,8 +75,8 @@
"ava": "^3.15.0",
"benny": "^3.7.1",
"chalk": "^4.1.2",
"esbuild": "^0.14.8",
"eslint": "^8.5.0",
"esbuild": "^0.14.11",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0",
Expand All @@ -87,7 +87,7 @@
"npm-run-all": "^4.1.5",
"oslllo-svg2": "^0.3.1",
"prettier": "^2.5.1",
"sharp": "^0.29.2",
"sharp": "^0.29.3",
"svg2img": "^0.9.4",
"typescript": "^4.5.4"
},
Expand Down
Loading

0 comments on commit 22e10ee

Please sign in to comment.