Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-plugin-extras

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-plugin-extras - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

52

index.d.ts
import File = require('vinyl');
export type Options = {
/**
Whether the plugin can handle directories.
@default false
*/
readonly supportsDirectories: boolean;
/**
An async generator function executed for finalization after all files have been processed.
You can yield more files from it if needed.
@example
```
import {gulpPlugin} from 'gulp-plugin-extras';
export default function gulpFoo() {
return gulpPlugin(
'gulp-foo',
async file => { … },
{
onFinish: async function * () {
yield someVinylFile;
yield someVinylFile2;
}
}
);
}
```
*/
readonly onFinish?: () => AsyncGenerator<File.BufferFile>;
};
/**

@@ -8,3 +42,2 @@ Create a Gulp plugin.

@param onFile - The async function called for each vinyl file in the stream. Must return a modified or new vinyl file.
@param onFinish - An async generator function executed for finalization after all files have been processed. You can yield more files from it if needed.

@@ -16,13 +49,6 @@ @example

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

@@ -34,3 +60,3 @@ ```

onFile: (file: File.BufferFile) => Promise<File.BufferFile>,
onFinish?: () => AsyncGenerator<File.BufferFile>
options?: Options
): NodeJS.ReadableStream;
import transformStream from 'easy-transform-stream';
import PluginError from './plugin-error.js';
export function gulpPlugin(name, onFile, onFinish) {
export function gulpPlugin(name, onFile, {onFinish, supportsDirectories} = {}) {
return transformStream(

@@ -10,3 +10,3 @@ {

async file => {
if (file.isNull()) {
if (file.isNull() && !(supportsDirectories && file.isDirectory())) {
return file;

@@ -13,0 +13,0 @@ }

{
"name": "gulp-plugin-extras",
"version": "0.1.0",
"version": "0.2.0",
"description": "Useful utilities for creating Gulp plugins",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -26,3 +26,3 @@ # gulp-plugin-extras

### `gulpPlugin(name, onFile, onFinish?)`
### `gulpPlugin(name, onFile, options?)`

@@ -45,4 +45,15 @@ Create a Gulp plugin.

#### onFinish
#### options
Type: `object`
##### supportsDirectories
Type: `boolean`\
Default: `false`
Whether the plugin can handle directories.
##### onFinish
Type: `async function * (): void`

@@ -61,5 +72,7 @@

async file => { … },
async function * () {
yield someVinylFile;
yield someVinylFile2;
{
onFinish: async function * () {
yield someVinylFile;
yield someVinylFile2;
}
}

@@ -66,0 +79,0 @@ );

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc