optipng-bin
Advanced tools
Comparing version 0.3.11 to 1.0.0
60
index.js
'use strict'; | ||
var BinBuild = require('bin-build'); | ||
var BinWrapper = require('bin-wrapper'); | ||
var fs = require('fs'); | ||
var logSymbols = require('log-symbols'); | ||
var path = require('path'); | ||
var pkg = require('./package.json'); | ||
var bin = require('./lib'); | ||
/** | ||
* Variables | ||
*/ | ||
var BIN_VERSION = '0.7.5'; | ||
var BASE_URL = 'https://raw.github.com/imagemin/optipng-bin/v' + pkg.version + '/vendor/'; | ||
/** | ||
* Initialize a new BinWrapper | ||
*/ | ||
var bin = new BinWrapper() | ||
.src(BASE_URL + 'osx/optipng', 'darwin') | ||
.src(BASE_URL + 'linux/x86/optipng', 'linux', 'x86') | ||
.src(BASE_URL + 'linux/x64/optipng', 'linux', 'x64') | ||
.src(BASE_URL + 'freebsd/optipng', 'freebsd') | ||
.src(BASE_URL + 'sunos/x86/optipng', 'sunos', 'x86') | ||
.src(BASE_URL + 'sunos/x64/optipng', 'sunos', 'x64') | ||
.src(BASE_URL + 'win/optipng.exe', 'win32') | ||
.dest(path.join(__dirname, 'vendor')) | ||
.use(process.platform === 'win32' ? 'optipng.exe' : 'optipng'); | ||
/** | ||
* Only run check if binary doesn't already exist | ||
*/ | ||
fs.exists(bin.use(), function (exists) { | ||
if (!exists) { | ||
bin.run(['--version'], function (err) { | ||
if (err) { | ||
console.log(logSymbols.warning + ' pre-build test failed, compiling from source...'); | ||
var builder = new BinBuild() | ||
.src('http://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-' + BIN_VERSION + '/optipng-' + BIN_VERSION + '.tar.gz') | ||
.cfg('./configure --with-system-zlib --prefix="' + bin.dest() + '" --bindir="' + bin.dest() + '"') | ||
.make('make install'); | ||
return builder.build(function (err) { | ||
if (err) { | ||
console.log(logSymbols.error, err); | ||
} | ||
console.log(logSymbols.success + ' optipng built successfully!'); | ||
}); | ||
} | ||
console.log(logSymbols.success + ' pre-build test passed successfully!'); | ||
}); | ||
} | ||
}); | ||
/** | ||
* Module exports | ||
*/ | ||
module.exports.path = bin.use(); | ||
module.exports.path = bin.path(); |
{ | ||
"name": "optipng-bin", | ||
"version": "0.3.11", | ||
"version": "1.0.0", | ||
"description": "OptiPNG wrapper that makes it seamlessly available as a local dependency on OS X, Linux, FreeBSD and Windows", | ||
"license": "BSD", | ||
"license": "MIT", | ||
"repository": "imagemin/optipng-bin", | ||
@@ -26,3 +26,3 @@ "author": { | ||
"scripts": { | ||
"postinstall": "node index.js", | ||
"postinstall": "node lib/install.js", | ||
"test": "mocha --reporter list --timeout 50000" | ||
@@ -32,3 +32,4 @@ }, | ||
"cli.js", | ||
"index.js" | ||
"index.js", | ||
"lib" | ||
], | ||
@@ -44,8 +45,8 @@ "keywords": [ | ||
"dependencies": { | ||
"bin-build": "^0.1.0", | ||
"bin-wrapper": "^0.3.0", | ||
"bin-build": "^0.2.0", | ||
"bin-wrapper": "^0.4.0", | ||
"log-symbols": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"bin-check": "^0.1.0", | ||
"bin-check": "^1.0.0", | ||
"mocha": "^1.18.2", | ||
@@ -52,0 +53,0 @@ "rimraf": "^2.2.6" |
# optipng-bin [![Build Status](https://secure.travis-ci.org/imagemin/optipng-bin.svg?branch=master)](http://travis-ci.org/imagemin/optipng-bin) | ||
[OptiPNG](http://optipng.sourceforge.net) 0.7.4 Node.js wrapper that makes it seamlessly available as a local dependency on OS X, Linux, FreeBSD, Solaris and Windows. | ||
> [OptiPNG](http://optipng.sourceforge.net) is a PNG optimizer that recompresses | ||
image files to a smaller size, without losing any information. | ||
> OptiPNG is a PNG optimizer that recompresses image files to a smaller size, without losing any information. | ||
## Install | ||
@@ -21,4 +20,8 @@ | ||
execFile(optipng, ['-v'], function (err, stdout, stderr) { | ||
console.log('OptiPNG version:', stdout.match(/\d\.\d\.\d/)[0]); | ||
execFile(optipng, ['-out', 'output.png', 'input.png'], function (err) { | ||
if (err) { | ||
throw err; | ||
} | ||
console.log('Image minified!'); | ||
}); | ||
@@ -41,4 +44,5 @@ ``` | ||
Everything excluding the binaries licensed under the [BSD license](http://opensource.org/licenses/bsd-license.php) and copyright Google. | ||
MIT © [imagemin](https://github.com/imagemin) | ||
OptiPNG licensed under the [zlib license](http://optipng.sourceforge.net/license.txt) and copyright Cosmin Truta and the Contributing Authors. | ||
OptiPNG licensed under the [zlib license](http://optipng.sourceforge.net/license.txt) | ||
and copyright Cosmin Truta and the Contributing Authors. |
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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6
0
65
1
47
1
4092
+ Addedarchive-type@0.1.4(transitive)
+ Addedarray-uniq@0.1.1(transitive)
+ Addedbin-build@0.2.0(transitive)
+ Addedbin-version@0.1.0(transitive)
+ Addedbin-version-check@0.1.0(transitive)
+ Addedbin-wrapper@0.4.0(transitive)
+ Addeddecompress@0.3.3(transitive)
+ Addeddecompress-tar@0.1.1(transitive)
+ Addeddecompress-targz@0.1.1(transitive)
+ Addeddecompress-unzip@0.1.2(transitive)
+ Addeddownload@0.2.4(transitive)
+ Addedeach-async@1.1.1(transitive)
+ Addedfind-versions@0.1.1(transitive)
+ Addedfs-extra@0.10.00.8.1(transitive)
+ Addedget-stdin@1.0.0(transitive)
+ Addedis-7zip@0.1.0(transitive)
+ Addedis-bzip2@0.1.0(transitive)
+ Addedis-gzip@0.1.0(transitive)
+ Addedis-rar@0.1.0(transitive)
+ Addedis-tar@0.1.1(transitive)
+ Addedis-zip@0.1.0(transitive)
+ Addedjsonfile@1.1.11.2.0(transitive)
+ Addedminimist@0.1.0(transitive)
+ Addedncp@0.4.20.5.1(transitive)
+ Addedonetime@1.1.0(transitive)
+ Addedread-chunk@0.1.0(transitive)
+ Addedrimraf@2.2.8(transitive)
+ Addedsemver@2.3.2(transitive)
+ Addedsemver-regex@0.1.1(transitive)
+ Addedset-immediate-shim@1.0.1(transitive)
+ Addedsimple-bufferstream@0.0.4(transitive)
+ Addedtemp-write@0.3.1(transitive)
+ Addedware@0.2.10.3.0(transitive)
- Removedbin-build@0.1.1(transitive)
- Removedbin-wrapper@0.3.4(transitive)
Updatedbin-build@^0.2.0
Updatedbin-wrapper@^0.4.0