napi-maybe-compressed-blob
Advanced tools
Comparing version 0.0.2 to 0.0.7
@@ -6,9 +6,3 @@ /* tslint:disable */ | ||
export class ExternalObject<T> { | ||
readonly '': { | ||
readonly '': unique symbol | ||
[K: symbol]: T | ||
} | ||
} | ||
export function compress(buf: Buffer): Buffer | ||
export function decompress(buf: Buffer): Buffer |
61
index.js
@@ -8,20 +8,49 @@ const { existsSync, readFileSync } = require('fs') | ||
let localFileExisted = false | ||
let isMusl = false | ||
let loadError = null | ||
function isMusl() { | ||
// For Node 10 | ||
if (!process.report || typeof process.report.getReport !== 'function') { | ||
try { | ||
const lddPath = require('child_process').execSync('which ldd').toString().trim(); | ||
return readFileSync(lddPath, 'utf8').includes('musl') | ||
} catch (e) { | ||
return true | ||
} | ||
} else { | ||
const { glibcVersionRuntime } = process.report.getReport().header | ||
return !glibcVersionRuntime | ||
} | ||
} | ||
switch (platform) { | ||
case 'android': | ||
if (arch !== 'arm64') { | ||
throw new Error(`Unsupported architecture on Android ${arch}`) | ||
switch (arch) { | ||
case 'arm64': | ||
localFileExisted = existsSync(join(__dirname, 'napi-maybe-compressed-blob.android-arm64.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./napi-maybe-compressed-blob.android-arm64.node') | ||
} else { | ||
nativeBinding = require('napi-maybe-compressed-blob-android-arm64') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
case 'arm': | ||
localFileExisted = existsSync(join(__dirname, 'napi-maybe-compressed-blob.android-arm-eabi.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./napi-maybe-compressed-blob.android-arm-eabi.node') | ||
} else { | ||
nativeBinding = require('napi-maybe-compressed-blob-android-arm-eabi') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
default: | ||
throw new Error(`Unsupported architecture on Android ${arch}`) | ||
} | ||
localFileExisted = existsSync(join(__dirname, 'napi-maybe-compressed-blob.android-arm64.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./napi-maybe-compressed-blob.android-arm64.node') | ||
} else { | ||
nativeBinding = require('napi-maybe-compressed-blob-android-arm64') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
@@ -126,4 +155,3 @@ case 'win32': | ||
case 'x64': | ||
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl') | ||
if (isMusl) { | ||
if (isMusl()) { | ||
localFileExisted = existsSync( | ||
@@ -157,4 +185,3 @@ join(__dirname, 'napi-maybe-compressed-blob.linux-x64-musl.node') | ||
case 'arm64': | ||
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl') | ||
if (isMusl) { | ||
if (isMusl()) { | ||
localFileExisted = existsSync( | ||
@@ -161,0 +188,0 @@ join(__dirname, 'napi-maybe-compressed-blob.linux-arm64-musl.node') |
{ | ||
"name": "napi-maybe-compressed-blob", | ||
"version": "0.0.2", | ||
"version": "0.0.7", | ||
"main": "index.js", | ||
@@ -10,3 +10,6 @@ "types": "index.d.ts", | ||
"additional": [ | ||
"aarch64-apple-darwin" | ||
"aarch64-apple-darwin", | ||
"aarch64-unknown-linux-gnu", | ||
"x86_64-apple-darwin", | ||
"x86_64-unknown-linux-gnu" | ||
] | ||
@@ -17,3 +20,3 @@ } | ||
"devDependencies": { | ||
"@napi-rs/cli": "^2.2.0", | ||
"@napi-rs/cli": "^2.11.4", | ||
"mocha": "9.1.3" | ||
@@ -33,7 +36,8 @@ }, | ||
"optionalDependencies": { | ||
"napi-maybe-compressed-blob-win32-x64-msvc": "0.0.2", | ||
"napi-maybe-compressed-blob-darwin-x64": "0.0.2", | ||
"napi-maybe-compressed-blob-linux-x64-gnu": "0.0.2", | ||
"napi-maybe-compressed-blob-darwin-arm64": "0.0.2" | ||
"napi-maybe-compressed-blob-win32-x64-msvc": "0.0.7", | ||
"napi-maybe-compressed-blob-darwin-x64": "0.0.7", | ||
"napi-maybe-compressed-blob-linux-x64-gnu": "0.0.7", | ||
"napi-maybe-compressed-blob-darwin-arm64": "0.0.7", | ||
"napi-maybe-compressed-blob-linux-arm64-gnu": "0.0.7" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22404
250
5
1