• This repository has been archived on 01/Sep/2022
  • Stars
    star
    830
  • Rank 52,617 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

This module has been deprecated. More information at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5

Here are some things you can use instead:

gulp-util NPM version Build Status Coveralls Status Dependency Status

Information

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

Usage

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

gutil.log('stuff happened', 'Really it did', gutil.colors.magenta('123'));

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. If you pass in multiple arguments it will join them by a space.

The default gulp coloring using gutil.colors.:

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

colors

Is an instance of chalk.

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 gutil.File({
  base: path.join(__dirname, './fixtures/'),
  cwd: __dirname,
  path: path.join(__dirname, './fixtures/test.coffee')
});

noop()

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

// gulp should be called like this :
// $ gulp --type production
gulp.task('scripts', function() {
  gulp.src('src/**/*.js')
    .pipe(concat('script.js'))
    .pipe(gutil.env.type === 'production' ? uglify() : gutil.noop())
    .pipe(gulp.dest('dist/'));
});

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) {
  
  }));

new PluginError(pluginName, message[, options])

  • pluginName should be the module name of your plugin
  • message can be a string or an existing error
  • By default the stack will not be shown. Set options.showStack to true if you think the stack is important for your error.
  • If you pass an error in as the message the stack will be pulled from that, otherwise one will be created.
  • Note that if you pass in a custom stack string you need to include the message along with that.
  • Error properties will be included in err.toString(). Can be omitted by including {showProperties: false} in the options.

These are all acceptable forms of instantiation:

var err = new gutil.PluginError('test', {
  message: 'something broke'
});

var err = new gutil.PluginError({
  plugin: 'test',
  message: 'something broke'
});

var err = new gutil.PluginError('test', 'something broke');

var err = new gutil.PluginError('test', 'something broke', {showStack: true});

var existingError = new Error('OMG');
var err = new gutil.PluginError('test', existingError, {showStack: true});

gulp-util for enterprise

Available as part of the Tidelift Subscription

The maintainers of gulp-util and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

More Repositories

1

gulp

A toolkit to automate & enhance your workflow
JavaScript
32,856
star
2

vinyl

Virtual file format.
JavaScript
1,261
star
3

vinyl-fs

Vinyl adapter for the file system.
JavaScript
963
star
4

liftoff

Launch your command line tool with ease.
JavaScript
836
star
5

gulp-cli

Command Line Interface for gulp.
JavaScript
392
star
6

plugins

[Unused] Very old plugin search website
JavaScript
280
star
7

interpret

A dictionary of file extensions and associated module loaders.
JavaScript
254
star
8

undertaker

Task registry that allows composition through series/parallel methods.
JavaScript
194
star
9

glob-stream

Readable streamx interface over anymatch.
JavaScript
178
star
10

bach

Compose your async functions with elegance.
JavaScript
132
star
11

fancy-log

Log things, prefixed with a timestamp.
JavaScript
119
star
12

findup-sync

Find the first file matching a given pattern in the current directory or the nearest ancestor directory.
JavaScript
97
star
13

glob-watcher

Watch globs and execute a function upon change, with intelligent defaults for debouncing and queueing.
JavaScript
79
star
14

glob-parent

Extract the non-magic parent path from a glob string.
JavaScript
76
star
15

async-done

Allows libraries to handle various caller provided asynchronous functions uniformly. Maps promises, observables, child processes and streams, and callbacks to callback style.
JavaScript
69
star
16

v8flags

Get available v8 and Node.js flags.
JavaScript
56
star
17

gulplog

Logger for gulp and gulp plugins
JavaScript
56
star
18

rechoir

Prepare a node environment to require files with different extensions.
JavaScript
47
star
19

replace-ext

Replaces a file extension with another one.
JavaScript
46
star
20

gulpjs.github.io

The gulp website
JavaScript
45
star
21

ordered-read-streams

Combines array of streams into one Readable stream in strict order.
JavaScript
28
star
22

now-and-later

Map over an array or object of values in parallel or series, passing each through the async iterator, with optional lifecycle hooks.
JavaScript
24
star
23

hacker

Hack on your project easily. A liftoff proof-of-concept.
JavaScript
23
star
24

flagged-respawn

A tool for respawning node binaries when special flags are present.
JavaScript
21
star
25

artwork

Artwork for the gulp project
21
star
26

plugin-error

Error handling for vinyl plugins. Just an abstraction of what's in gulp-util with minor reformatting.
JavaScript
21
star
27

empty-dir

Check if a directory is empty.
JavaScript
20
star
28

sparkles

Namespaced global event emitter
JavaScript
20
star
29

acceptance

Acceptance test suite for plugins
19
star
30

undertaker-forward-reference

Undertaker custom registry supporting forward referenced tasks.
JavaScript
19
star
31

glogg

Global logging utility.
JavaScript
18
star
32

lead

Sink your streams.
JavaScript
17
star
33

undertaker-registry

Default registry in gulp 4.
JavaScript
17
star
34

vinyl-sourcemap

Add/write sourcemaps to/from Vinyl files.
JavaScript
15
star
35

last-run

Capture and retrieve the last time a function was run
JavaScript
14
star
36

path-dirname

Node.js path.dirname() ponyfill
JavaScript
13
star
37

fined

Find a file given a declaration of locations.
JavaScript
12
star
38

async-settle

Settle an async function. It will always complete successfully with an object of the resulting state.
JavaScript
11
star
39

value-or-function

Normalize a value or function, applying extra args to the function
JavaScript
11
star
40

copy-props

Copy properties deeply between two objects
JavaScript
10
star
41

to-through

Wrap a Readable stream in a Transform stream.
JavaScript
10
star
42

semver-greatest-satisfied-range

Find the greatest satisfied semver range from an array of ranges.
JavaScript
9
star
43

mute-stdout

Mute and unmute stdout
JavaScript
9
star
44

resolve-options

Resolve an options object based on configuration.
JavaScript
9
star
45

has-gulplog

Check if gulplog is available before attempting to use it
JavaScript
9
star
46

clone-buffer

Easier Buffer cloning in node.
JavaScript
9
star
47

eslint-config-gulp

Sharable eslint config for gulp projects
JavaScript
8
star
48

async-once

Guarantee a node-style async function is only executed once.
JavaScript
8
star
49

fs-mkdirp-stream

Ensure directories exist before writing to them.
JavaScript
8
star
50

undertaker-common-tasks

Proof-of-concept custom registry that pre-defines tasks.
JavaScript
7
star
51

remove-bom-stream

Remove a UTF8 BOM at the start of the stream.
JavaScript
7
star
52

registry

[Unused] NPM on ElasticSearch
JavaScript
5
star
53

better-stats

A replacement for node's fs.Stats with more utility
JavaScript
5
star
54

theming-log

Creates a logger with theme for text decoration.
JavaScript
4
star
55

undertaker-task-metadata

Proof-of-concept custom registry that attaches metadata to each task.
JavaScript
4
star
56

vinyl-contents

Utility to read the contents of a vinyl file.
JavaScript
4
star
57

replace-homedir

Replace user home in a string with another string. Useful for tildifying a path.
JavaScript
4
star
58

each-props

Process object properties deeply.
JavaScript
3
star
59

evented-require

Require modules and receive events.
JavaScript
3
star
60

update-template

Updates a gulpjs repository to match our current scaffold.
JavaScript
3
star
61

.github

GitHub template files for the gulpjs organization.
3
star
62

vinyl-prepare

[deprecated] This module's API was never satisfactory and isn't used in gulp - please don't use.
JavaScript
3
star
63

.boilerplate

The boilerplate template for gulp packages.
3
star
64

parse-node-version

Turn node's process.version into something useful.
JavaScript
2
star
65

default-resolution

Get the default resolution time based on the current node version, optionally overridable
JavaScript
2
star
66

jscs-preset-gulp

Sharable jscs config for gulp projects
2
star
67

conventional-changelog-gulp

conventional-changelog gulp preset
JavaScript
1
star
68

emit-mapper

Re-emit events while mapping them to new names.
JavaScript
1
star