diff --git a/.gitattributes b/.gitattributes index 391f0a4..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff --git a/.travis.yml b/.travis.yml index efc9bbe..2ae9d62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ -sudo: false language: node_js node_js: - - "10" - - "8" - - "6" + - '10' + - '8' + - '6' diff --git a/index.js b/index.js index 82ac615..7e5e4db 100644 --- a/index.js +++ b/index.js @@ -31,16 +31,16 @@ const getDefaultPlugins = () => return plugins.concat(instance); }, []); -module.exports = (plugins, opts) => { +module.exports = (plugins, options) => { if (typeof plugins === 'object' && !Array.isArray(plugins)) { - opts = plugins; + options = plugins; plugins = null; } - opts = Object.assign({ - // TODO: remove this when gulp get's a real logger with levels + options = Object.assign({ + // TODO: Remove this when Gulp gets a real logger with levels verbose: process.argv.includes('--verbose') - }, opts); + }, options); const validExts = ['.jpg', '.jpeg', '.png', '.gif', '.svg']; @@ -62,7 +62,7 @@ module.exports = (plugins, opts) => { } if (!validExts.includes(path.extname(file.path).toLowerCase())) { - if (opts.verbose) { + if (options.verbose) { log(`${PLUGIN_NAME}: Skipping unsupported image ${chalk.blue(file.relative)}`); } @@ -87,7 +87,7 @@ module.exports = (plugins, opts) => { totalFiles++; } - if (opts.verbose) { + if (options.verbose) { log(`${PLUGIN_NAME}:`, chalk.green('✔ ') + file.relative + chalk.gray(` (${msg})`)); } @@ -95,7 +95,7 @@ module.exports = (plugins, opts) => { cb(null, file); }) .catch(error => { - // TODO: remove this setImmediate when gulp 4 is targeted + // TODO: Remove this setImmediate when Gulp 4 is targeted setImmediate(cb, new PluginError(PLUGIN_NAME, error, {fileName: file.path})); }); }, cb => { diff --git a/readme.md b/readme.md index 4a0ee7c..9c30230 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,8 @@ -# gulp-imagemin [![Build Status](https://travis-ci.org/sindresorhus/gulp-imagemin.svg?branch=master)](https://travis-ci.org/sindresorhus/gulp-imagemin) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) +# gulp-imagemin [![Build Status](https://travis-ci.com/sindresorhus/gulp-imagemin.svg?branch=master)](https://travis-ci.com/sindresorhus/gulp-imagemin) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) -> Minify PNG, JPEG, GIF and SVG images with [imagemin](https://github.com/imagemin/imagemin) +> Minify PNG, JPEG, GIF and SVG images with [`imagemin`](https://github.com/imagemin/imagemin) -*Issues with the output should be reported on the imagemin [issue tracker](https://github.com/imagemin/imagemin/issues).* +*Issues with the output should be reported on the [`imagemin` issue tracker](https://github.com/imagemin/imagemin/issues).* --- @@ -36,7 +36,7 @@ gulp.task('default', () => ### Custom plugin options ```js -… +// … .pipe(imagemin([ imagemin.gifsicle({interlaced: true}), imagemin.jpegtran({progressive: true}), @@ -48,32 +48,42 @@ gulp.task('default', () => ] }) ])) -… +// … ``` Note that you may come across an older, implicit syntax. In versions < 3, the same was written like this: ```js -… +// … .pipe(imagemin({ interlaced: true, progressive: true, optimizationLevel: 5, - svgoPlugins: [{removeViewBox: true}] + svgoPlugins: [ + { + removeViewBox: true + } + ] })) -… +// … ``` ### Custom plugin options and custom `gulp-imagemin` options ```js -… +// … .pipe(imagemin([ - imagemin.svgo({plugins: [{removeViewBox: true}]}) + imagemin.svgo({ + plugins: [ + { + removeViewBox: true + } + ] + }) ], { verbose: true })) -… +// … ```