Skip to content

Commit

Permalink
Deprecate gulp-util
Browse files Browse the repository at this point in the history
  • Loading branch information
1000ch committed Jan 19, 2018
1 parent 8e920af commit 6ab7afa
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 15 deletions.
25 changes: 14 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

const { extname } = require('path');
const through2 = require('through2-concurrent');
const gutil = require('gulp-util');
const PluginError = require('plugin-error');
const colors = require('ansi-colors');
const log = require('fancy-log');
const replaceExtension = require('replace-ext');
const filesize = require('filesize');
const { round10 } = require('round10');
const optimize = require('./optimize');
Expand All @@ -23,7 +26,7 @@ module.exports = options => through2.obj({
const extension = extname(file.path).toLowerCase();

if (!SUPPORTED_EXTENSIONS.includes(extension)) {
gutil.log('gulp-image: Skipping unsupported image ' + gutil.colors.blue(file.relative));
log('gulp-image: Skipping unsupported image ' + colors.blue(file.relative));
return callback(null, file);
}

Expand All @@ -43,23 +46,23 @@ module.exports = options => through2.obj({
const diffPercent = round10(100 * (diff / before), -1);

if (diff <= 0) {
gutil.log(
gutil.colors.green('- ') + file.relative + gutil.colors.gray(' ->') +
gutil.colors.gray(' Cannot improve upon ') + gutil.colors.cyan(filesize(before))
log(
colors.green('- ') + file.relative + colors.gray(' ->') +
colors.gray(' Cannot improve upon ') + colors.cyan(filesize(before))
);
} else {
file.contents = buffer;

gutil.log(
gutil.colors.green('✔ ') + file.relative + gutil.colors.gray(' ->') +
gutil.colors.gray(' before=') + gutil.colors.yellow(filesize(before)) +
gutil.colors.gray(' after=') + gutil.colors.cyan(filesize(after)) +
gutil.colors.gray(' reduced=') + gutil.colors.green.underline(filesize(diff) + '(' + diffPercent + '%)')
log(
colors.green('✔ ') + file.relative + colors.gray(' ->') +
colors.gray(' before=') + colors.yellow(filesize(before)) +
colors.gray(' after=') + colors.cyan(filesize(after)) +
colors.gray(' reduced=') + colors.green(filesize(diff) + '(' + diffPercent + '%)')
);
}

callback(null, file);
}).catch(error => {
callback(new gutil.PluginError('gulp-image', error));
callback(new PluginError('gulp-image', error));
});
});
114 changes: 111 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@
"url": "https://github.com/1000ch/gulp-image/issues"
},
"dependencies": {
"ansi-colors": "^1.0.1",
"exec-buffer": "^3.2.0",
"fancy-log": "^1.3.2",
"filesize": "^3.5.0",
"gifsicle": "^3.0.3",
"guetzli": "^1.0.1",
"gulp-util": "^3.0.7",
"is-gif": "^1.0.0",
"is-jpg": "^1.0.0",
"is-png": "^1.1.0",
"is-svg": "^2.1.0",
"jpeg-recompress-bin": "^3.0.1",
"mozjpeg": "^5.0.0",
"optipng-bin": "^4.0.0",
"plugin-error": "^1.0.0",
"pngquant-bin": "^3.1.0",
"replace-ext": "^1.0.0",
"round10": "^1.0.3",
"svgo": "^1.0.2",
"through2-concurrent": "^1.1.1",
Expand Down

0 comments on commit 6ab7afa

Please sign in to comment.