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 28, 2017
1 parent
c13d748
commit e0b6e76
Showing
10 changed files
with
47 additions
and
74 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,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,10 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
var spawn = require('child_process').spawn; | ||
var jpegRecompress = require('./'); | ||
var input = process.argv.slice(2); | ||
const spawn = require('child_process').spawn; | ||
const jpegRecompress = require('.'); | ||
|
||
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,2 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./lib').path(); |
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,14 @@ | ||
'use strict'; | ||
|
||
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 path = require('path'); | ||
const BinWrapper = require('bin-wrapper'); | ||
const pkg = require('../package.json'); | ||
|
||
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') | ||
.src(`${url}osx/jpeg-recompress`, 'darwin') | ||
.src(`${url}linux/jpeg-recompress`, 'linux') | ||
.src(`${url}win/jpeg-recompress.exe`, 'win32') | ||
.dest(path.join(__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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,30 @@ | ||
/*global afterEach,beforeEach,it*/ | ||
'use strict'; | ||
|
||
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'); | ||
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('..'); | ||
|
||
beforeEach(function () { | ||
mkdirp.sync(tmp); | ||
test('return path to binary and verify that it is working', async t => { | ||
t.true(await binCheck(jpegRecompress, ['--version'])); | ||
}); | ||
|
||
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(); | ||
}); | ||
}); | ||
|
||
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]); | ||
}); |