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 🙏

© 2026 – Pkg Stats / Ryan Hefner

gulp-newy

v2.0.4

Published

Determines if source file is newer than destination file(or if one exists)

Readme

Build Status

Visit gulp-newy.com for screen shots, examples, and more

Install

$ npm install --save-dev gulp-newy

alt text

Usage

Using a single callback function, you have complete control.
var newy = require('gulp-newy');

newy(function(projectDir, srcFile, absSrcFile) {
    
   // Newy hands you the project directory, source file,
   // and source file with aboslute path as the args.
   
   // You can build, construct, and mutate the absolute 
   // path and filename with the args. 
   // Return your new destination file with absolute path. 

   // Cut and paste callback function in examples for ease.
})

Result

-------------------- Newy Message ------------------
File [source filename] is new/newer then [destination filename returned from your callback]
----------------------------------------------------

Example Callback Functions


Many to one comparison

Compare less files in /home/one/github/foo/app/css/*.less against single file /home/one/github/foo/compiled/css/application.css

var newy = require('gulp-newy');
var path = require('path');

function lessVersusOneFile(projectDir, srcFile, absSrcFile) {
    // Newy gives projectDir arg wich is '/home/one/github/foo/`
    var compareFileAgainst = "compiled/css/application.css";

    var destinationFile = path.join(projectDir, compareFileAgainst);
    // distinationFile returned will be /home/one/github/foo/compiled/css/application.css

    return destinationFile;
}
// all *.less files will be compared against
// /home/one/github/foo/compiled/css/application.css

gulp.task('compileLessToCss', function () {
    return gulp.src('app/css/**/*.less')
        .pipe(newy(lessVersusOneFile))
        .pipe(less())
        .pipe(gulp.dest('compiled/css'));
});

One to one comparison

Compare coffee script files in /home/one/github/foo/app/js/*.coffee against compiled Javascript files in /home/one/github/foo/compiled/js/*.js

  • note: child directories and files will be globed with no issues
var newy = require('gulp-newy');
var path = require('path');

function coffeeVersusJs(projectDir, srcFile, absSrcFile) {
    // newy gives projectDir arg wich is '/home/one/github/foo/`
    var stripPath = "app";
    var destDir = "compiled/js";
    var newSuffix = ".js"

    var re = new RegExp("^\/.*"+stripPath+"\/");
    var relativeSourceFile = absSrcFile.replace(re, "");
    var destinationFile = path.join(projectDir, destDir, relativeSourceFile);

    destinationFile = destination.substr(0, destination.lastIndexOf(".")) + newSuffix;
    // srcFile is error.service.coffee
    // destination file returned is 
    // /home/one/github/foo/compiled/js/fooBar/services/error-services/error.service.js
    
    return destinationFile;
}

gulp.task('compile-coffee', function () {
    return gulp.src('app/js/**/*.coffee')
          .pipe(newy(coffeeVersusJs))
          .pipe(coffee({bare: true}))
          .pipe(gulp.dest('compiled/js'));
});

FAQs

  • It's ok if directory in the absolute path doesn't exist, but newy will let you know as a courtesy warning in case it was unintentional.
  • If there is no destination file, newy will automatically count file as new and pipe it through as any other file that is newer.
  • Always be sure to return the destination file with a absolute path, not a relative path. projectDir is given to you for this.

Notes

  • Why doesn't gulp-newy use options instead of a callback? Because 'one size does not fit all'. I have found with other modules of the same type I was restricted and could not do what I needed.
  • Why aren't you using batch style operations? Think about this stream as a gas pump filling your car....do you want a steady stream or do you want a bottle neck of operation end results all released at once which will still end up a steady stream?
  • Why aren't you using node process.nextTick or setImmediate for async-like behavior? The majority of operations here are I/O operations. This means they are natively non-blocking. Using these apis would only gaurantee that each job runs next in the event queue...which is unnecessary. If you really wanted to set this behavior, it can be done in the gulp wraped task.
  • What does all this mean? A code free of overhead software gives you less issues and bugs. Think of food that is orgranic and more healthy.
available at alt text