Socket
Socket
Sign inDemoInstall

gulp-read

Package Overview
Dependencies
17
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gulp-read

Gulp plugin to read vinyl file contents


Version published
Maintainers
1
Install size
285 kB
Created

Readme

Source

npm Version Build Status Coverage Status Dependency Status devDependency Status Code Climate Codacy Badge

gulp-read

Gulp plugin to read vinyl file contents.

Installation

npm install --save-dev gulp-read

Usage

Basically whenever you can get away with using read:false at the beginning of a stream, but you still need the file contents at a later stage. Here's what a typical example might look like:

var gulp = require('gulp');
var changed = require('gulp-changed');
var read = require('gulp-read');
var imagemin = require('gulp-imagemin');
var remember = require('gulp-remember');

gulp.task('image', function() {
  return gulp.src('images/**', {read:false})
    .pipe(changed('dist/images'))
    .pipe(read())
    .pipe(imagemin())
    .pipe(remember())
    .pipe(gulp.dest('dist/images'));
});

In the above we don't have to read file contents initially since all gulp-changed cares about is the last modification date of each file.

After the unchanged files have been removed from the stream the contents of the remaining files are then read by gulp-read so they can be processed by gulp-imagemin.

In effect we never have to read the contents of files that haven't changed which saves time and speeds up the build.

Compatibiliy

Since this plugin is basically identical to the get-contents module of vinyl-fs it shouldn't make a difference whether file contents are read by gulp.src() or gulp-read.

API

read([options])

Reads the contents for each vinyl file from disk.

Options

  • buffer: Whether or not the file contents should be a Buffer. Setting this to false will make file.contents a stream. (Default: true)
  • force: Whether or not to reread file contents if they already exist. (Default: false)
  • stripBOM: Whether or not to strip the BOM from file contents. (Default: true)

License

MIT

Keywords

FAQs

Last updated on 07 Aug 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc