Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle lld not found #46

Merged
merged 1 commit into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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