gulp-plugin-extras
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -12,2 +12,13 @@ import File = require('vinyl'); | ||
/** | ||
Whether the plugin can handle any Vinyl file type. | ||
Useful for custom type filtering. | ||
Supersedes `supportsDirectories`. | ||
@default false | ||
*/ | ||
readonly supportsAnyType: boolean; | ||
/** | ||
An async generator function executed for finalization after all files have been processed. | ||
@@ -26,3 +37,3 @@ | ||
{ | ||
onFinish: async function * () { | ||
async * onFinish() { | ||
yield someVinylFile; | ||
@@ -45,2 +56,6 @@ yield someVinylFile2; | ||
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._ | ||
@example | ||
@@ -47,0 +62,0 @@ ``` |
18
index.js
import transformStream from 'easy-transform-stream'; | ||
import PluginError from './plugin-error.js'; | ||
export function gulpPlugin(name, onFile, {onFinish, supportsDirectories} = {}) { | ||
export function gulpPlugin(name, onFile, { | ||
onFinish, | ||
supportsDirectories = false, | ||
supportsAnyType = false, | ||
} = {}) { | ||
return transformStream( | ||
@@ -10,8 +14,10 @@ { | ||
async file => { | ||
if (file.isNull() && !(supportsDirectories && file.isDirectory())) { | ||
return file; | ||
} | ||
if (!supportsAnyType) { | ||
if (file.isNull() && !(supportsDirectories && file.isDirectory())) { | ||
return file; | ||
} | ||
if (file.isStream()) { | ||
throw new PluginError(name, 'Streaming not supported'); | ||
if (file.isStream()) { | ||
throw new PluginError(name, 'Streaming not supported'); | ||
} | ||
} | ||
@@ -18,0 +24,0 @@ |
{ | ||
"name": "gulp-plugin-extras", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "Useful utilities for creating Gulp plugins", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -32,3 +32,3 @@ # gulp-plugin-extras | ||
*This does not support streaming.* | ||
*This does not support streaming unless you enable the `supportsAnyType` option.* | ||
@@ -58,2 +58,13 @@ #### name | ||
##### supportsAnyType | ||
Type: `boolean`\ | ||
Default: `false` | ||
Whether the plugin can handle any Vinyl file type. | ||
Useful for custom type filtering. | ||
Supersedes `supportsDirectories`. | ||
##### onFinish | ||
@@ -75,3 +86,3 @@ | ||
{ | ||
onFinish: async function * () { | ||
async * onFinish() { | ||
yield someVinylFile; | ||
@@ -78,0 +89,0 @@ yield someVinylFile2; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9975
208
92