From 25f6754a71dfa4736c75eb91bf9f2562543f5d08 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 19 Jan 2022 17:20:27 +0800 Subject: [PATCH] fix(cli): js binding template --- cli/src/js-binding-template.ts | 43 +++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/cli/src/js-binding-template.ts b/cli/src/js-binding-template.ts index e865d30d..1b2659e6 100644 --- a/cli/src/js-binding-template.ts +++ b/cli/src/js-binding-template.ts @@ -16,28 +16,43 @@ function isMusl() { try { return readFileSync('/usr/bin/ldd', 'utf8').includes('musl') } catch (e) { - return false + return true } } else { const { glibcVersionRuntime } = process.report.getReport().header - return !Boolean(glibcVersionRuntime) + return !glibcVersionRuntime } } switch (platform) { case 'android': - if (arch !== 'arm64') { - throw new Error(\`Unsupported architecture on Android \${arch}\`) - } - localFileExisted = existsSync(join(__dirname, '${localName}.android-arm64.node')) - try { - if (localFileExisted) { - nativeBinding = require('./${localName}.android-arm64.node') - } else { - nativeBinding = require('${pkgName}-android-arm64') - } - } catch (e) { - loadError = e + switch (arch) { + case 'arm64': + localFileExisted = existsSync(join(__dirname, '${localName}.android-arm64.node')) + try { + if (localFileExisted) { + nativeBinding = require('./${localName}.android-arm64.node') + } else { + nativeBinding = require('${pkgName}-android-arm64') + } + } catch (e) { + loadError = e + } + break + case 'arm': + localFileExisted = existsSync(join(__dirname, '${localName}.android-arm-eabi.node')) + try { + if (localFileExisted) { + nativeBinding = require('./${localName}.android-arm-eabi.node') + } else { + nativeBinding = require('${pkgName}-android-arm-eabi') + } + } catch (e) { + loadError = e + } + break + default: + throw new Error(\`Unsupported architecture on Android \${arch}\`) } break case 'win32':