fix(cli): allow more platform & arch fallback to wasm (#1969)

This commit is contained in:
LongYinan 2024-02-22 16:42:33 +08:00 committed by GitHub
parent 0306e3045a
commit da99081ccf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -93,7 +93,7 @@ switch (platform) {
} }
break break
default: default:
throw new Error(\`Unsupported architecture on Android \${arch}\`) loadError = new Error(\`Unsupported architecture on Android \${arch}\`)
} }
break break
case 'win32': case 'win32':
@ -141,7 +141,7 @@ switch (platform) {
} }
break break
default: default:
throw new Error(\`Unsupported architecture on Windows: \${arch}\`) loadError = new Error(\`Unsupported architecture on Windows: \${arch}\`)
} }
break break
case 'darwin': case 'darwin':
@ -182,22 +182,37 @@ switch (platform) {
} }
break break
default: default:
throw new Error(\`Unsupported architecture on macOS: \${arch}\`) loadError = new Error(\`Unsupported architecture on macOS: \${arch}\`)
} }
break break
case 'freebsd': case 'freebsd':
if (arch !== 'x64') { switch (arch) {
throw new Error(\`Unsupported architecture on FreeBSD: \${arch}\`) case 'x64':
} localFileExisted = existsSync(join(__dirname, '${localName}.freebsd-x64.node'))
localFileExisted = existsSync(join(__dirname, '${localName}.freebsd-x64.node')) try {
try { if (localFileExisted) {
if (localFileExisted) { nativeBinding = require('./${localName}.freebsd-x64.node')
nativeBinding = require('./${localName}.freebsd-x64.node') } else {
} else { nativeBinding = require('${pkgName}-freebsd-x64')
nativeBinding = require('${pkgName}-freebsd-x64') }
} } catch (e) {
} catch (e) { loadError = e
loadError = e }
break
case 'arm64':
localFileExisted = existsSync(join(__dirname, '${localName}.freebsd-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./${localName}.freebsd-arm64.node')
} else {
nativeBinding = require('${pkgName}-freebsd-arm64')
}
} catch (e) {
loadError = e
}
break
default:
loadError = new Error(\`Unsupported architecture on FreeBSD: \${arch}\`)
} }
break break
case 'linux': case 'linux':