Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1000ch
committed
Mar 29, 2017
1 parent
c13d748
commit 29c027d
Showing
11 changed files
with
55 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
* text=auto | ||
*.js text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- 'iojs' | ||
- '0.12' | ||
- '0.10' | ||
- 6 | ||
- 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
const spawn = require('child_process').spawn; | ||
const jpegRecompress = require('.'); | ||
|
||
var spawn = require('child_process').spawn; | ||
var jpegRecompress = require('./'); | ||
var input = process.argv.slice(2); | ||
const input = process.argv.slice(2); | ||
|
||
spawn(jpegRecompress, input, {stdio: 'inherit'}) | ||
.on('exit', process.exit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const BinWrapper = require('bin-wrapper'); | ||
const pkg = require('../package.json'); | ||
|
||
var path = require('path'); | ||
var BinWrapper = require('bin-wrapper'); | ||
var pkg = require('../package.json'); | ||
var url = 'https://raw.github.com/imagemin/jpeg-recompress-bin/v' + pkg.version + '/vendor/'; | ||
const url = `https://raw.github.com/imagemin/jpeg-recompress-bin/v${pkg.version}/vendor/`; | ||
|
||
module.exports = new BinWrapper() | ||
.src(url + 'osx/jpeg-recompress', 'darwin') | ||
.src(url + 'linux/jpeg-recompress', 'linux') | ||
.src(url + 'win/jpeg-recompress.exe', 'win32') | ||
.dest(path.join(__dirname, '../vendor')) | ||
.src(`${url}osx/jpeg-recompress`, 'darwin') | ||
.src(`${url}linux/jpeg-recompress`, 'linux') | ||
.src(`${url}win/jpeg-recompress.exe`, 'win32') | ||
.dest(path.resolve(__dirname, '../vendor')) | ||
.use(process.platform === 'win32' ? 'jpeg-recompress.exe' : 'jpeg-recompress'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,29 @@ | ||
/*global afterEach,beforeEach,it*/ | ||
'use strict'; | ||
const path = require('path'); | ||
const test = require('ava'); | ||
const execa = require('execa'); | ||
const tempy = require('tempy'); | ||
const binCheck = require('bin-check'); | ||
const compareSize = require('compare-size'); | ||
const jpegRecompress = require('..'); | ||
|
||
var assert = require('assert'); | ||
var execFile = require('child_process').execFile; | ||
var path = require('path'); | ||
var binCheck = require('bin-check'); | ||
var compareSize = require('compare-size'); | ||
var mkdirp = require('mkdirp'); | ||
var rimraf = require('rimraf'); | ||
var tmp = path.join(__dirname, 'tmp'); | ||
|
||
beforeEach(function () { | ||
mkdirp.sync(tmp); | ||
}); | ||
|
||
afterEach(function () { | ||
rimraf.sync(tmp); | ||
}); | ||
|
||
it('return path to binary and verify that it is working', function (cb) { | ||
binCheck(require('../'), ['--version'], function (err, works) { | ||
assert(!err); | ||
assert(works); | ||
cb(); | ||
}); | ||
test('return path to binary and verify that it is working', async t => { | ||
t.true(await binCheck(jpegRecompress, ['--version'])); | ||
}); | ||
|
||
it('minify a JPG', function (cb) { | ||
var src = path.join(__dirname, 'fixtures/test.jpg'); | ||
var dest = path.join(tmp, 'test.jpg'); | ||
var args = [ | ||
test('minify a JPG', async t => { | ||
const tmp = tempy.directory(); | ||
const src = path.join(__dirname, 'fixtures/test.jpg'); | ||
const dest = path.join(tmp, 'test.jpg'); | ||
const args = [ | ||
'--quality', 'high', | ||
'--min', '60', | ||
src, | ||
dest | ||
]; | ||
|
||
execFile(require('../'), args, function (err) { | ||
assert(!err); | ||
await execa(jpegRecompress, args); | ||
const res = await compareSize(src, dest); | ||
|
||
compareSize(src, dest, function (err, res) { | ||
assert(!err); | ||
assert(res[dest] < res[src]); | ||
cb(); | ||
}); | ||
}); | ||
t.true(res[dest] < res[src]); | ||
}); |