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-remaster

v1.1.0

Published

A gulp plugin that allows you to edit Vinyl files directly.

Downloads

4

Readme

Gulp Remaster

"The Last Gulp Plugin"

Not the last gulp plugin anyone will ever write, but the last one that absolutely must be written or the plugin of last resort. Remaster is a gulp plugin that allows you to edit Vinyl files directly in your gulp task as they come through the stream. Essentially it is a meta-plugin; if you can't find a plugin that does what you need, use Remaster to get a hold of the Vinyl file objects yourself and edit them.

You could also write a gulp plugin by wrapping Remaster.

Use

Like other gulp plugins, Remaster is used by passing an invocation of Remaster to the .pipe() method of a readable Vinyl stream. By default, Remaster will behave much like gulp-clone in that it will make a clone of all Vinyl files found in the stream and pass them on. A more useful invocation of Remaster will pass a file handler function to be run on each file and, optionally, a final handler function to be invoked after the last file is processed but before the stream is closed. There is also an options object syntax that allows setting both handler functions and a few other options.

If you wanted to build something like a simplistic gulp-filter, you could invoke Remaster something like this:

var gulp = require('gulp'),
    remaster = require('gulp-remaster');

var filterPattern = /-test$/;

gulp.task('example', function(){
  return gulp.src("src/**/*.js")
    .pipe(remaster( function(file, done){
      if(file.isNull || filterPattern.test(file.stem)) {
        // remove file from the stream by calling the callback
        // without an error or a file.
        return done();
      }
      // pass the file on by passing it to the callback
      done(null, file);
    }))
    .pipe(gulp.dest("dest"));
})

Take a look at the tests for more examples.

API

remaster( eachFileHandler[, finalHandler] ) or remaster( options )

eachFileHandler( file[, encoding], callback ) or eachFile

Default: internal passthrough file handler

This is really just a thinly wrapped through2 transform function. For each file in the stream it receives either the file and a callback([err[, file]]) or the file, it's encoding, and a callback([err[, file]]). Remaster will send an error to the callback if it encounters a file (object) that is not a vinyl file (i.e. what gulp streams usually contain.) The callback takes an err - for reporting errors - and a file, which will be pushed to the stream. As with through2, this is set to the stream, so you may call this.push(file) instead of passing the file to the callback.

finalHandler(callback) or final

Default: undefined

This is a through2 flush function. It receives a single callback([err]) which may be passed an error and should be called when you are done with the stream.

copy

Default: true

If truthy, Remaster will clone all Vinyl files passed through the stream before passing the clone to the eachFile handler. If an object, it will be passed as an options object to clone.

strict

Default: undefined

If truthy, Remaster will check whether every object coming through the stream is a Vinyl file using Vinyl's own test function. This option exists and is off by default in case your workflow passes through things that act like Vinyl files, but are not. You can turn it on if you want to be sure every file object is truely a Vinyl file.

createError

Default: internal PluginError constructor

This is a function that will call the gulp-util PluginError constructor used to generate errors inside Remaster. It is exposed here in case you want to use Remaster to simplify writing your own gulp plugin. In that case only, set this to your own function that calls gulp-util's PluginError constructor.

Additional Reading

Using Remaster is essentially Writing a Gulp Plugin. You may find the section on modifying file content particularly relevant. Keep in mind that Remaster is just as useful for modifying Vinyl metadata as it is the file contents themselves.