Comparing version 0.1.0 to 0.1.1
14
index.js
@@ -12,6 +12,6 @@ 'use strict'; | ||
*/ | ||
var bin = new BinWrapper() | ||
.src('https://raw.github.com/1000ch/node-cwebp-bin/master/vendor/osx/cwebp', 'darwin') | ||
.src('https://raw.github.com/1000ch/node-cwebp-bin/master/vendor/linux/cwebp', 'linux') | ||
.src('https://raw.github.com/1000ch/node-cwebp-bin/master/vendor/win/cwebp.exe', 'win64') | ||
.dest(path.join(__dirname, 'vendor')) | ||
@@ -23,3 +23,2 @@ .use('cwebp'); | ||
*/ | ||
fs.exists(bin.use(), function (exists) { | ||
@@ -33,4 +32,4 @@ if (!exists) { | ||
bin.run(args, function (err) { | ||
if (err) { | ||
bin.run(args, function (error) { | ||
if (error) { | ||
console.log(chalk.red('✗ pre-build test failed, compiling from source...')); | ||
@@ -42,5 +41,5 @@ | ||
return builder.build(function (err) { | ||
if (err) { | ||
return console.log(chalk.red('✗ ' + err)); | ||
return builder.build(function (error) { | ||
if (error) { | ||
return console.log(chalk.red('✗ ' + error)); | ||
} | ||
@@ -60,3 +59,2 @@ | ||
*/ | ||
module.exports.path = bin.use(); |
{ | ||
"name": "cwebp-bin", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "cwebp node.js wrapper that convert JPG or PNG into WebP", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -1,1 +0,48 @@ | ||
# node-cwebp-bin | ||
# node-cwebp-bin | ||
[![Build Status](https://travis-ci.org/1000ch/node-cwebp-bin.svg?branch=master)](https://travis-ci.org/1000ch/node-cwebp-bin) | ||
[![NPM version](https://badge.fury.io/js/cwebp-bin.svg)](http://badge.fury.io/js/cwebp-bin) | ||
[![Dependency Status](https://david-dm.org/1000ch/node-cwebp-bin.svg)](https://david-dm.org/1000ch/node-cwebp-bin) | ||
[![devDependency Status](https://david-dm.org/1000ch/node-cwebp-bin/dev-status.svg)](https://david-dm.org/1000ch/node-cwebp-bin#info=devDependencies) | ||
## Dependency | ||
WebP requires following libraries. See [detail](https://developers.google.com/speed/webp/docs/compiling). | ||
### Linux | ||
```sh | ||
$ sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libgif-dev | ||
``` | ||
### Mac OS X | ||
```sh | ||
$ sudo port install jpeg libpng tiff giflib | ||
``` | ||
## Install | ||
```sh | ||
$ npm install --save cwebp-bin | ||
``` | ||
## Usage | ||
```js | ||
var execFile = require('child_process').execFile; | ||
var cwebp = require('cwebp-bin').path; | ||
execFile(cwebp, ['input.png', '-o', 'output.webp'], function (error) { | ||
if (error) { | ||
throw error; | ||
} | ||
console.log('Image was converted'); | ||
}); | ||
``` | ||
## License | ||
This is licensed under BSD. | ||
WebP is licensed under [Creative Commons Attribution 3.0 License](http://creativecommons.org/licenses/by/3.0/). |
@@ -52,9 +52,22 @@ /*global afterEach, beforeEach, describe, it */ | ||
'-o', | ||
path.join(__dirname, 'tmp/test.webp') | ||
path.join(__dirname, 'tmp/test-png.webp') | ||
]; | ||
execFile(binPath, args, function () { | ||
callback(assert(fs.statSync(path.join(__dirname, 'tmp/test.webp')))); | ||
callback(assert(fs.statSync(path.join(__dirname, 'tmp/test-png.webp')))); | ||
}); | ||
}); | ||
it('should convert JPG to WebP', function (callback) { | ||
var binPath = require('../').path; | ||
var args = [ | ||
path.join(__dirname, 'fixtures/test.jpg'), | ||
'-o', | ||
path.join(__dirname, 'tmp/test-jpg.webp') | ||
]; | ||
execFile(binPath, args, function () { | ||
callback(assert(fs.statSync(path.join(__dirname, 'tmp/test-jpg.webp')))); | ||
}); | ||
}); | ||
}); |
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
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
128740
111
48