node-pngcrush
Advanced tools
Comparing version 0.1.9 to 0.2.0
@@ -1,43 +0,47 @@ | ||
var fs = require("fs"), | ||
path = require("path"), | ||
name = "png_compress.node", | ||
tryList, i, count, file, vars; | ||
/** | ||
* 0.8.0-0.8.25 : 0.8.0 | ||
* 0.9.9-0.10.13 : 0.9.9 | ||
* 0.9.2-0.9.8: 0.9.2 | ||
* 0.9.1-0.9.1: 0.9.1 | ||
* 0.9.0-0.9.0: 0.9.0 | ||
*/ | ||
vars = [ | ||
'0.8.0', | ||
'0.9.9', | ||
'0.12.0' | ||
]; | ||
tryList = [ | ||
path.join(__dirname, "build", "Release", name) // build dir | ||
]; | ||
'use strict'; | ||
for (i = 0, count = vars.length; i < count; i++) { | ||
tryList.push(path.join(__dirname, "lib", process.platform, process.arch, vars[i], name)); | ||
function compiler(a, b) { | ||
if (!/^(?:\d+.?)+$/.test(a) || !/^(?:\d+.?)+/.test(b)) { | ||
return a > b; | ||
} | ||
var aArr = a.split('.'); | ||
var bArr = b.split('.'); | ||
var max = Math.max(aArr.length, bArr.length); | ||
for (var i = 0; i < max; i++) { | ||
if ((aArr[i] && !bArr[i]) || aArr[i] > bArr[i]) { | ||
return 1; | ||
} else if ((!aArr[i] && bArr[i]) || aArr[i] < bArr[i]) { | ||
return -1; | ||
} | ||
} | ||
return 0; | ||
} | ||
count = tryList.length; | ||
for (i = 0; i < count; i++) { | ||
file = tryList[i]; | ||
if (fs.existsSync(file)) { | ||
try { | ||
exports = require(file); | ||
} catch (e) { | ||
continue; // try next | ||
var pkgInf = require('./package.json'); | ||
var bindingMap = pkgInf.bindingMap; | ||
var bugUrl = pkgInf['bugs'] ? (pkgInf['bugs']['url'] || '') : ''; | ||
for ( var i in bindingMap) { | ||
if (bindingMap.hasOwnProperty(i)) { | ||
var target = i; | ||
var versions = bindingMap[i]; | ||
var cur = process.versions['node']; | ||
if (compiler(versions[0], cur) <= 0 && compiler(versions[1], cur) >= 0) { | ||
try { | ||
module.exports = require('./bindings/'+ process.platform + '/' + process.arch + '/' + target + '/png_compress.node'); | ||
return; | ||
} catch ( e ) { | ||
throw new Error('Can\'t load the addon. Issue to: ' + bugUrl + ' ' + e.stack); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
if (exports && exports.PngCompress) { | ||
module.exports = exports; | ||
} else { | ||
throw new Error("Can't load addon."); | ||
} | ||
throw new Error('Can\'t load the addon. Issue to: ' + bugUrl); |
{ | ||
"name": "node-pngcrush", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"description": "The node-pngcrush is an addon of node, as a readable/writable stream", | ||
@@ -9,2 +9,16 @@ "main": "index.js", | ||
}, | ||
"bindingMap": { | ||
"0.8.0": [ | ||
"0.8.0", | ||
"0.8.25" | ||
], | ||
"0.9.9": [ | ||
"0.10.0", | ||
"0.10.99" | ||
], | ||
"0.12.0": [ | ||
"0.12.0", | ||
"0.12.99" | ||
] | ||
}, | ||
"scripts": { | ||
@@ -11,0 +25,0 @@ "test": "echo \"Error: no test specified\" && exit 1", |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 4 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 4 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10315054
1
59