npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-intermediate2

v1.0.3

Published

A gulp helper for tools that need files on disk.

Downloads

117

Readme

gulp-intermediate2

GitHub release Build and Test Status

Semantic Versioning Conventional Commits

This plugin is a modern version of gulp-intermediate. Fully support various encodings and streaming mode.

A gulp helper for tools that need files on disk.

Some tools require access to files on disk instead of working with stdin and stdout (e.g., Jekyll, Ruby Sass). gulp-intermediate2 is a convenience plugin that writes the current vinyl stream to a temporary directory, lets you run commands on the file system, and pushes the results back into the pipe.

NOTE: Writing intermediate files to disk is counter to the gulp philosophy. If possible, use a tool that works with streams. Use gulp-intermediate2 only if other (better) options aren't available.

Install

npm install --save-dev gulp-intermediate2

Usage

var gulp = require('gulp');
var spawn = require('child-process').spawn;
var intermediate2 = require('gulp-intermediate2');

gulp.task('default', function () {
  return gulp.src('**/*', { encoding: false })
    .pipe(intermediate2(
      {
        destOptions: { encoding: false },
        srcOptions: { encoding: false }
      },
      function (srcDirPath, destDirPath, callback) {
        // Run a command on the files in tempDir and write the results to
        // the specified output directory.
        spawn('a_command', ['--dest', '_site'], {cwd: tempDir});
          .on('close', cb);
      }
    ))
    .pipe(gulp.dest(testDestFilesPath))
});

With streaming mode:

var gulp = require('gulp');
var spawn = require('child-process').spawn;
var intermediate2 = require('gulp-intermediate2');

gulp.task('default', function () {
  return gulp.src('**/*', { encoding: false, buffer: false })
    .pipe(plugin.intermediate2(
      {
        destOptions: { encoding: false },
        srcOptions: { encoding: false, buffer: false },
        container: 'test-container',
        output: 'test-output'
      },
      function (srcDirPath, destDirPath, callback) {
        // Run a command on the files in tempDir and write the results to
        // the specified output directory.
        spawn('a_command', ['--dest', '_site'], {cwd: tempDir});
          .on('close', cb);
      }
    ))
    .pipe(gulp.dest(testDestFilesPath, { encoding: false }))
});

API

intermediate2([options], [process])

options

Type: object Optional

destOptions

Type: object Optional

All options, supported by gulp.dest. Options for writing input Vinyl files to temp directory.

srcOptions

Type: object Optional

All options, supported by gulp.src. Options for reading output files from the temp output directory after the process is completed.

output

Type: string Default: '.'

The directory read back into the stream when processing is finished. Relative to tempDir\<uniqueID>.

container

Type: string Default: random uuid

The directory that input files are written to. Relative to tempDir\<uniqueID>.

The container is emptied before every run.

process(srcDirPath, destDirPath, cb)

Type: function

Run your commands. process comes with three arguments:

  • srcDirPath: The absolute path to the directory containing your input temporary files.
  • destDirPath: The absolute path to the directory containing your output temporary files.
  • cb: A callback function to call when the processing is finished. It pushes the output files (from destDirPath) back into the gulp stream.

Notes

The files are written to tempDir using the vinyl file object's relative path, with gulp.dest().