gulp-plugin-extras
Useful utilities for creating Gulp plugins
Last updated 3 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install gulp-plugin-extras 
SYNC missed versions from official npm registry.

gulp-plugin-extras

Useful utilities for creating Gulp plugins

Install

npm install gulp-plugin-extras

Usage

import {gulpPlugin} from 'gulp-plugin-extras';

export default function gulpFoo() {
	return gulpPlugin('gulp-foo', async file => {
		file.contents = await someKindOfTransformation(file.contents);
		return file;
	});
}

API

gulpPlugin(name, onFile, options?)

Create a Gulp plugin.

If you throw an error with a .isPresentable = true property, it will not display the error stack.

This does not support streaming unless you enable the supportsAnyType option.

name

Type: string

The plugin name.

onFile

Type: async (file) => file

The async function called for each Vinyl file in the stream. Must return a modified or new Vinyl file.

options

Type: object

supportsDirectories

Type: boolean
Default: false

Whether the plugin can handle directories.

supportsAnyType

Type: boolean
Default: false

Whether the plugin can handle any Vinyl file type.

Useful for custom type filtering.

Supersedes supportsDirectories.

onFinish

Type: async function * (stream: NodeJS.ReadableStream): void

An async generator function executed for finalization after all files have been processed.

You can yield more files from it if needed.

import {gulpPlugin} from 'gulp-plugin-extras';

export default function gulpFoo() {
	return gulpPlugin(
		'gulp-foo',
		async file => { … },
		{
			async * onFinish() {
				yield someVinylFile;
				yield someVinylFile2;
			}
		}
	);
}

Current Tags

  • 1.1.0                                ...           latest (2 years ago)

7 Versions

  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.2                                ...           3 years ago
  • 0.2.1                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Maintainers (1)
Downloads
Total 47
Today 0
This Week 11
This Month 32
Last Day 1
Last Week 5
Last Month 9
Dependencies (3)
Dev Dependencies (5)

© 2010 - cnpmjs.org x YWFE | Home | YWFE