Adds an.isBinary()
function to thefile
object, similar tofile.isNull()
andfile.isStream()
.
Install
Install with npm:$ npm install --save gulp-is-binary
Usage
var gulp = require('gulp');
var isBinary = require('gulp-is-binary');
gulp.task('default', function() {
return gulp.src('some/files/*.*')
.pipe(isBinary())
});
Example usage
var gulp = require('gulp');
var isBinary = require('gulp-is-binary');
gulp.task('default', function() {
return gulp.src('some/files/*.*')
.pipe(isBinary()) // this adds the `.isBinary()` property to the file object
.pipe(through.obj(function(file, enc, next) {
// `file.isBinary()` will check the file to see if it's binary,
// so we can avoid reading and potentially corrupting the file
if (file.isBinary()) {
next(null, file);
return;
}
// do stuff, now that we know that file.contents isn't binary
next(null, file);
}));
});
About
Related projects
- file-contents: Set the
contents
property on a file object. Abstraction from vinyl-fs to support stream or… more | homepage - file-is-binary: Returns true if a file is binary. Checks the actual contents, since extensions are not… more | homepage
- file-stat: Set the
stat
property on a file object. Abstraction from vinyl-fs to support stream or… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.Building docs
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running tests
Install dev dependencies:$ npm install && npm test
Author
Jon SchlinkertLicense
Copyright © 2017, Jon Schlinkert. MITThis file was generated by verb-generate-readme, v0.4.2, on January 30, 2017.