gulpjs / gulp-util

[deprecated] - See https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

more helpful replacement pointers

Spongman opened this issue · comments

please add some more helpful replacement pointers to the README.

for example, noop points to through2 as a replacement, but it doesn't mention how to use through2 to do this and it's not immediately clear from the through2 docs how to do this.

please add some simple translations of the examples in the 'Usage' section to the recommended replacements.

@Spongman
noop is equivalent to () => through2.obj(). I agree it could be clearer. If you don't use the return value, an empty function should be enough. Calling noop returns a pass-through stream in object mode.

I'll take some time during the week-end to compile a list of examples of common cases I encountered while helping other modules to migrate.

How about suggesting gulp-noop (github)?

Personally I'd prefer that a PassThrough stream was used directly, but I suppose it is implementation details.

I am a bit confused by the suggestion to replace gutil.buffer with list-stream. Seems like the more well known bl or concat-stream would be more applicable.

Edit: Oh, I guess bl does not support objectMode, making it a non-starter.

Adding to this - there is no suggested replacement for gulp-decompress

I encountered it using Gatsby:

gatsby-plugin-sharp@1.6.43
  └─┬ imagemin-pngquant@5.0.1
    └─┬ pngquant-bin@3.1.1
      └─┬ bin-build@2.2.0
        └─┬ download@4.4.3
          └─┬ gulp-decompress@1.2.0
            └── gulp-util@3.0.8 

@katekourbatova You are reading this issue incorrectly. This is about improving suggestions for changing plugins using gulp-util. The case you are displaying is that gulp-decompress needs to follow this advice.

Tools should not be replacing whole plugins because they in turn depend on gulp-util. The proper thing to do is have gulp-decompress replace their usage of gulp-util (which is already done kevva/gulp-decompress@d3fdff1).

So for this case specifically, someone in the dependency chain needs to upgrade a version so that a newer version of gulp-decompress is used.

@katekourbatova In fact, it looks like gatsby-plugin-sharp@next solves your issue (though for some reason npm install is still showing the gulp-util deprecation notice, not sure why).

gutil.File => https://www.npmjs.com/package/vinyl
gutil.replaceExtension => The .extname property on Vinyl objects or https://www.npmjs.com/package/replace-ext
gutil.colors => https://www.npmjs.com/package/ansi-colors
gutil.date => https://www.npmjs.com/package/date-format
gutil.log => https://www.npmjs.com/package/fancy-log
gutil.template => https://www.npmjs.com/package/lodash.template
gutil.env => https://www.npmjs.com/package/minimist
gutil.beep => https://www.npmjs.com/package/beeper
gutil.noop => https://www.npmjs.com/package/through2
gutil.isStream => Use the .isStream() method on Vinyl objects
gutil.isBuffer => Use the .isBuffer() method on Vinyl objects
gutil.isNull => Use the .isNull() method on Vinyl objects
gutil.linefeed => Use the string '\n' in your code
gutil.combine => https://www.npmjs.com/package/multipipe
gutil.buffer => https://www.npmjs.com/package/list-stream
gutil.PluginError => https://www.npmjs.com/package/plugin-error

As a recent newcomer I found it frustrating to get a pointer to "though2" for noop.
I managed to make a couple of noops (a comment above helped) but not a friendly entry.

import through2 from 'through2'
import transfob from 'transfob';

async function noop2() {
	return () => through2.obj()
}
async function noop1() {
	transfob( function( file, enc, next ) {
			next( null, file );
	})
}