New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-each

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-each

A for each that provides the raw file content.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.4K
increased by7.53%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-each

Build Test Coverage Code Climate Downloads Version ISC License Analytics

A for-each for Gulp that exposes the actual content of the file.

I have had to write this code many times because I wanted a "one-off" task that does "somthing quick" to each file. Or, I have wanted to write literally any module that processes code files, and had to start anew every time and figure out this logic.

Most other for-each implementations for Gulp expose the stream (of buffer) object, requiring the user to read the stream (or buffer) and write out a new stream (or buffer). Yes, I used the most annoying way to word that on purpose. This module exposes the content of the file itself, so you can directly start manipulating the content (e.g. code) directly, without worrying about the Gulp plumbing.

Download

npm install gulp-each

Usage

var each = require('gulp-each');

gulp.task('mytask', function() {
    gulp.src('*.js')
        .pipe(each(function(content, file, callback) {
            // content is a string containing the code
            // do with it as you'd like
            var newContent = '// my comment\n' + content;
            
            // file is the original Vinyl file object
            
            // return the new content using the callback
            // the first argument is an error, if you encounter one
            callback(null, newContent);
        })
        .pipe(gulp.dest('output'));
});

Note: it's worth saying that this implementation of for-each is most valuable when working with text files. It may not function as expected when working with binary files.

Keywords

FAQs

Package last updated on 07 Sep 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc