{"id":16739278,"url":"https://github.com/olehdutchenko/gulp-not-supported-file","last_synced_at":"2026-04-24T22:32:42.137Z","repository":{"id":57258365,"uuid":"92305152","full_name":"OlehDutchenko/gulp-not-supported-file","owner":"OlehDutchenko","description":"Check the file before process it in your Gulp plugin","archived":false,"fork":false,"pushed_at":"2018-01-04T06:17:50.000Z","size":129,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-14T08:18:51.036Z","etag":null,"topics":["buffer","development","file","gulp","gulp-plugin","stream","through2"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OlehDutchenko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-24T15:02:25.000Z","updated_at":"2017-05-26T17:21:06.000Z","dependencies_parsed_at":"2022-08-25T19:12:35.575Z","dependency_job_id":null,"html_url":"https://github.com/OlehDutchenko/gulp-not-supported-file","commit_stats":null,"previous_names":["dutchenkooleg/gulp-not-supported-file"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/OlehDutchenko/gulp-not-supported-file","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fgulp-not-supported-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fgulp-not-supported-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fgulp-not-supported-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fgulp-not-supported-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OlehDutchenko","download_url":"https://codeload.github.com/OlehDutchenko/gulp-not-supported-file/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fgulp-not-supported-file/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262026906,"owners_count":23246951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buffer","development","file","gulp","gulp-plugin","stream","through2"],"created_at":"2024-10-13T00:49:52.795Z","updated_at":"2026-04-24T22:32:37.117Z","avatar_url":"https://github.com/OlehDutchenko.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-not-supported-file\n\n![npm](https://img.shields.io/badge/node-6.3.1-yellow.svg)\n[![es2015](https://img.shields.io/badge/ECMAScript-2015_(ES6)-blue.svg)](https://nodejs.org/en/docs/es6/)\n[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/dutchenkoOleg/gulp-not-supported-file/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/dutchenkoOleg/gulp-not-supported-file.svg?branch=master)](https://travis-ci.org/dutchenkoOleg/gulp-not-supported-file)\n\n\u003e _Not a Gulp plugin,_  \n\u003e _but for Gulp plugin developers._  \n\u003e _Check the file before process it in your Gulp plugin_\n\n[![js-happiness-style](https://cdn.rawgit.com/JedWatson/happiness/master/badge.svg)](https://github.com/JedWatson/happiness)\n\n## What is this and why it was created?\n\nMost of Gulp plugins for compiling/rendering static files use [through2](https://www.npmjs.com/package/through2) for processing. And first step of each code is a testing file  \n\\- it is not null  \n\\- it is not stream  \n\\- it is not ...  \nAnd after this checkouts we may work with file.\n\n_Little example_\n\n```js\nconst through2 = require('through2');\nconst PluginError = require('plugin-error');\nconst PLUGIN_NAME = 'my-plugin';\n\nfunction myGulpPLugin(options) {\n\t// process options if need\n\t// ...\n\t\n\t// processing\n\treturn through2.obj(function(file, enc, cb) {\n\t\tif (file.isNull()) {\n\t\t\treturn cb(null, file);\n\t\t}\n\t\t\n\t\tif (file.isStream()) {\n\t\t\treturn cb(new PluginError(PLUGIN_NAME, 'Streaming not supported'));\n\t\t}\n\t\t\n\t\tif (!file.contents.length) {\n\t\t\treturn cb(null, file);\n\t\t}\n\t\t\n\t\t// and other if and if\n\t\t// ...\n\t\t\n\t\t// and then work with it\n\t});\n}\n```\n\n\u003e _I'm tired of writing the same code every time._  \n\u003e _So I wrote it once and wrapped it in a tiny module._\n\n---\n\n## How it works\n\nCall this module with your file and with your plugin error handler. Module will return result:\n\n- `false` if the file is suitable for work\n- `Array` if the file failed the test. Array will contain arguments. First of them is text status name of fail and next arguments for `through2` callback.\n\n***Status list***\n\n- `'isDirectory'` - will be error\n- `'isNull'` - will be error\n- `'isStream'` - will be error\n- `'isEmpty'` - skip file\n- `'isUnderscore'` - skip file\n\n***Usage example***\n\n```js\nconst through2 = require('through2');\nconst PluginError = require('plugin-error');\nconst PLUGIN_NAME = 'my-plugin';\n\nconst notSupportedFile = require('gulp-not-supported-file');\n\n// ---------------------------\n\t\n// private method plugin error\nfunction pluginError (data, errorOptions) {\n\treturn new PluginError(PLUGIN_NAME, data, errorOptions);\n}\n\n// core plugin method\nfunction myGulpPlugin(options) {\n\t// process options if need\n\t// ...\n\t\n\t// processing\n\treturn through2.obj(function (file, enc, cb) {\n\t\tlet notSupported = notSupportedFile(file, pluginError);\n\t\t\n\t\tif (Array.isArray(notSupported)) {\n\t\t\tnotSupported.shift();       // or with saving -\u003e let failStatus = notSupported.shift();\n\t\t\treturn cb(...notSupported); // or es5 apply -\u003e cb.apply(null, notSupported);\n\t\t}\n\t\t\n\t\t// work with file if passed\n\t\t// ...\n\t});\n}\n\nmodule.exports = myGulpPlugin;\n\n```\n\n### Module also has few options\n\nOptions are passed by the third argument and must be an `object`\n\n```js\nlet notSupported = notSupportedFile(file, pluginError, options);\n```\n\n\n\n#### `noUnderscore`\n\ntype `boolean` /\ndefault `true`\n\nFile with empty content will be skipped and not using in stream next.  \n\n_You will receive message in console if it happens_  \n_Example of log:_\n\n![no-empty log example](https://raw.githubusercontent.com/dutchenkoOleg/gulp-not-supported-file/master/assets/no-underscore.png)\n\n\n#### `noEmpty`\n\ntype `boolean` /\ndefault `true`\n\nFile with empty content will be skipped and not using in stream next.  \nReturn `['isEmpty']`  \n_**Note!** Spaces, tabs and newlines will be treated as empty content._  \n \n_You will receive message in console if it happens_stream next._  \n_Example of log:_\n\n![no-empty log example](https://raw.githubusercontent.com/dutchenkoOleg/gulp-not-supported-file/master/assets/no-empty.png)\n\n#### `silent`\n\ntype `boolean` /\ndefault `false`\n\nNo logs about `noEmpty` and `noUnderscore` files\n\n---\n\n## Installing\n\n```shell\nnpm install --save gulp-not-supported-file\n# or using yarn cli\nyarn add gulp-not-supported-file\n```\n\n## Tests\n\n1. `npm test` for testing code style and run mocha tests\n1. `npm run happiness-fix` for automatically fix most of problems with code style \n\n## Changelog\n\nPlease read [CHANGELOG.md](https://github.com/dutchenkoOleg/gulp-not-supported-file/blob/master/CHANGELOG.md)\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://github.com/dutchenkoOleg/gulp-not-supported-file/blob/master/CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folehdutchenko%2Fgulp-not-supported-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folehdutchenko%2Fgulp-not-supported-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folehdutchenko%2Fgulp-not-supported-file/lists"}