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

@averay/gulp-clean-unmodified

v1.0.2

Published

A Gulp plugin to remove unmodified files after tasks have completed.

Downloads

10

Readme

@averay/gulp-clean-unmodified

View code coverage on codecov

A Gulp plugin to remove unmodified files after tasks have completed.

A usual Gulp workflow is first cleaning the destination directory, then writing the generated files to it. For situations where the destination directory is being watched or otherwise in use, the gap between the old files being removed and the new files being written can cause issues or unnecessary reloads. This plugin allows reversing the order, by first writing the generated files to the destination directory (overwriting any existing files), then after going through and removing any outdated files, ensuring files that persist the previous build and the new build remain present throughout the process.

Usage

For simple cases, first import the plugin:

import cleaner from '@averay/gulp-clean-unmodified';

Next, register created files by piping .register() in to the end of all streams:

export function css() {
  gulp.src('src/**/*.scss')
    // (Other plugins)
    .pipe(gulp.dest('dest'))
    .pipe(cleaner.register());
}

Finally, call .clean() in a subsequent task to remove unmodified files, providing the path to the output directory root:

// Either async
export async function clean() {
  cleaner.clean('dest');
}
// or using a callback
export function clean(done) {
  cleaner.clean('dest');
  done();
}

(Note that for a simple clean task like this either the function must be asynchronous or invoke the callback to prevent Gulp incomplete task errors.)

The two tasks must then be run in series:

export const build = gulp.series(css, clean);

See the example gulpfile.

Parallel Outputs

For advanced Gulp usage with parallel-but-unrelated destinations (e.g. bundling a Node app and compiling static web assets in the same gulpfile), separate cleaner instances should be created and generated files piped into the appropriate instance's processor, to allow the separate components to operate independently. See the example gulpfile.


MIT License