JSPM

  • Created
  • Published
  • Downloads 987466
  • Score
    100M100P100Q58181F

Utility functions for gulp plugins

Package Exports

  • gulp-util
  • gulp-util/lib/PluginError
  • gulp-util/lib/PluginError.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gulp-util) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

status

Information

Packagegulp-util
Description Utility functions for gulp plugins
Node Version >= 0.9

Usage

var gutil = require('gulp-util');

gutil.log("stuff happened", "Really it did", gutil.colors.cyan("123"));
gutil.beep();

gutil.replaceExtension("file.coffee", ".js"); // file.js

var opt = {
  name: "todd",
  file: someGulpFile
};
gutil.template("test <%= name %> <%= file.path %>", opt) // test todd /js/hi.js

log(msg...)

Logs stuff. Already prefixed with [gulp] and all that. Use the right colors for values. If you pass in multiple arguments it will join them by a space.

values (files, module names, etc.) = magenta
numbers (times, counts, etc) = cyan

colors

This is an instance of chalk

linefeed

Just \n. Use this.

replaceExtension(path, newExtension)

Replaces a file extension in a path. Returns the new path.

isStream(obj)

Returns true or false if an object is a stream.

isBuffer(obj)

Returns true or false if an object is a Buffer.

template(string[, data])

This is a lodash.template function wrapper. You must pass in a valid gulp file object so it is available to the user or it will error. You can not configure any of the delimiters. Look at the lodash docs for more info.

new File(obj)

This is just vinyl

var file = new gulp.File({
  base: join(__dirname, "./fixtures/"),
  cwd: __dirname,
  path: join(__dirname, "./fixtures/test.coffee")
});

noop()

Returns a stream that does nothing but pass data straight through.

gulp.task('scripts', function() {
  gulp.src('src/**/*.js')
    .pipe(concat('script.js'))
    .pipe(gulp.env.production ? uglify() : gutil.noop())
    .pipe(gulp.dest('dist/');
});

combine(streams...)

Argument may also be an array of streams. Returns a function that returns the combined stream. Useful for keeping things DRY. This is a simple wrapper around event-stream's .pipeline

var scripts = gutil.combine(
    coffee({bare: true}),
    uglify(),
    concat('script.js'),
    gulp.dest('dist/')
);

gulp.task('default', function() {
  gulp.src('*.coffee').pipe(scripts());
});

buffer(cb)

This is similar to es.wait but instead of buffering text into one string it buffers anything into an array (so very useful for file objects).

Returns a stream that can be piped to.

The stream will emit one data event after the stream piped to it has ended. The data will be the same array passed to the callback.

Callback is optional and receives two arguments: error and data

gulp.src("stuff/*.js")
  .pipe(gutil.buffer(function(err, files){
  
  });

LICENSE

(MIT License)

Copyright (c) 2013 Fractal contact@wearefractal.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.