Skip to content

Commit

Permalink
1.2.0 release
Browse files Browse the repository at this point in the history
Closes #9
Closes #10

commit 8ac884e
Author: Stan Hutcheon <stanhutcheon@bigfork.co.uk>
Date:   Thu Oct 29 15:40:56 2015 +0000

    Bump to 1.2.0

commit 2d06a42
Author: Stan Hutcheon <stanhutcheon@bigfork.co.uk>
Date:   Thu Oct 29 15:40:31 2015 +0000

    Fix spacing typo in dependencies

commit a2793c4
Author: Stan Hutcheon <stanhutcheon@bigfork.co.uk>
Date:   Mon Oct 26 16:46:40 2015 +0000

    Update travis node versions

commit bc94dba
Author: Stan Hutcheon <stanhutcheon@bigfork.co.uk>
Date:   Mon Oct 26 16:33:37 2015 +0000

    Add docs for parallel uploads

commit 03a1574
Author: Stan Hutcheon <stanhutcheon@bigfork.co.uk>
Date:   Mon Oct 26 16:09:26 2015 +0000

    Add configurable max concurrency

commit 24cc033
Author: Stan Hutcheon <stanhutcheon@bigfork.co.uk>
Date:   Mon Oct 26 16:04:55 2015 +0000

    Output correct amount of skipped files

    actually closes #10

commit a3b3ee4
Author: Stan Hutcheon <stanhutcheon@bigfork.co.uk>
Date:   Mon Oct 26 12:59:41 2015 +0000

    Add untested parallel upload support
  • Loading branch information
Stan Hutcheon committed Oct 29, 2015
1 parent 55be23a commit 5cf0062
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
language: node_js
node_js:
- "4.1"
- "4.0"
- "0.12"
- "0.11"
- "0.10"
- "0.8"
- "0.6"
- "iojs"
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ Default: `false`

Set to true to log errors & messages to the console. Errors are dispatched via events anyway, so plugins like `gulp-plumber` can handle these for you.

#### options.parallel
Type: `Boolean`
Default: `true`

Enables concurrent uploads to the TinyPNG server to speed up total compression time.

<sub>(thanks [HugoHeneault](https://github.com/HugoHeneault) for this feature suggestion)</sub>

#### options.parallelMax
Type: `Integer`
Default: `5`

The amount of concurrent uploads allowed at one time, increase if you/your request limits can handle it - very easy to max out your monthly requests, use with caution!

#### options.force
Type: `Boolean` / `String`
Default: `false`
Expand Down
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var test = process.env.NODE_ENV == 'test',
through = require('through2'),
throughParallel = require('through2-concurrent'),
gutil = require('gulp-util'),
chalk = gutil.colors,
request = require('request'),
Expand Down Expand Up @@ -28,7 +29,9 @@ function TinyPNG(opt, obj) {
log: false,
force: false, ignore: false,
sameDest: false,
summarize: false
summarize: false,
parallel: true,
parallelMax: 5
}
};

Expand Down Expand Up @@ -66,7 +69,7 @@ function TinyPNG(opt, obj) {
opt = this.conf.options,
emitted = false;

return through.obj(function(file, enc, cb) {
return (opt.parallel ? throughParallel : through).obj({maxConcurrency: opt.parallelMax}, function(file, enc, cb) {
if(self.utils.glob(file, opt.ignore)) return cb();

if(file.isNull()) {
Expand Down Expand Up @@ -128,6 +131,7 @@ function TinyPNG(opt, obj) {
})
.on('error', function(err) {
emitted = true; // surely a method in the stream to handle this?
self.stats.skipped++;
self.utils.log(err.message);
})
.on('end', function() {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-tinypng-compress",
"version": "1.1.8",
"version": "1.2.0",
"description": "TinyPNG API wrapper for compressing PNG & JPG images",
"main": "index.js",
"repository": "stnvh/gulp-tinypng-compress",
Expand Down Expand Up @@ -38,7 +38,8 @@
"dependencies": {
"gulp-util": "~3.0.0",
"request": "~2.55.0",
"through2": "~0.6.0",
"through2": "^2.0.0",
"through2-concurrent": "^1.1.0",
"minimatch": "^2.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit 5cf0062

Please sign in to comment.