Skip to content

Commit

Permalink
Support a quiet option.
Browse files Browse the repository at this point in the history
  • Loading branch information
elyobo authored and 1000ch committed Feb 18, 2018
1 parent 289680c commit d6d2f13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ const { extname } = require('path');
const through2 = require('through2-concurrent');
const PluginError = require('plugin-error');
const colors = require('ansi-colors');
const log = require('fancy-log');
const fancyLog = require('fancy-log');
const replaceExtension = require('replace-ext');
const filesize = require('filesize');
const { round10 } = require('round10');
const optimize = require('./optimize');

const SUPPORTED_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif', '.svg'];
const NOOP = () => {};

module.exports = options => through2.obj({
maxConcurrency: options ? options.concurrent : null
Expand All @@ -23,6 +24,7 @@ module.exports = options => through2.obj({
return callback(new Error('gulp-image: Streaming is not supported'));
}

const log = options && options.quiet ? NOOP : fancyLog;
const extension = extname(file.path).toLowerCase();

if (!SUPPORTED_EXTENSIONS.includes(extension)) {
Expand Down
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ gulp.task('image', function () {
guetzli: false,
gifsicle: true,
svgo: true,
concurrent: 10
concurrent: 10,
quiet: true // defaults to false
}))
.pipe(gulp.dest('./dest'));
});
```

Set `false` for optimizers which you don't want to apply. And you can set `concurrent` option to limit the max concurrency in execution.
Set `false` for optimizers which you don't want to apply. And you can set `concurrent` option to limit the max concurrency in execution. You can also set `quiet` to avoid logging out results for every image processed.

You can configure parameters applied to each optimizers such as following:

Expand Down

0 comments on commit d6d2f13

Please sign in to comment.