@cjser/gulp-plugin-extras__v0_1_0
v0.1.0-cjser.2
Published
Useful utilities for creating Gulp plugins
Readme
gulp-plugin-extras
Useful utilities for creating Gulp plugins
Install
npm install gulp-plugin-extrasUsage
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, onFinish?)
Create a Gulp plugin.
This does not support streaming.
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.
onFinish
Type: async function * (): 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 function * () {
yield someVinylFile;
yield someVinylFile2;
}
);
}cjser
This package is a CommonJS-compatible build generated by cjser for projects that still need require() support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.
Original repository: https://github.com/sindresorhus/gulp-plugin-extras
