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-cache-money

v1.1.0

Published

A gulp caching system that saves to disk.

Downloads

186

Readme

Gulp Cache Money

Cache money is a gulp plugin that only runs the plugin if any of the files have changed. It saves the cache to a file called '.gulp-cache'.

Build status

Installation

Install via npm:

$ npm install --save-dev gulp-cache-money

Usage

Just add pass cache into the gulp chain right after you src your files.

var cache = require("gulp-cache-money")({
    cacheFile: __dirname + "/.cache"
});

gulp.task(function() {
    gulp.src("index.js")
        .pipe(
            cache() // Pipe in the cacher
            .on("cache-report", function(hits) { 
                console.log("%d cache hits.", hits.length); // Log how many hits
            })
        )
        .pipe(browserify())
        .dest("/build.js");
});

cache = cached( options )

This is the function exported from gulp-cache-money. Pass in an options object to configure the cache. The returned function is what you (call and) pass into your gulp build chain. gulp-cache-money works by md5'ing any incoming files and comparing the hashes, if none of the files within the vinyl-fs file stream have changed, the stream ends there otherwise all files are pushed down the chain.

  • cacheFile (String) -- The path to where you want to store you cache. Defaults to .gulp-cache in the directory of the entry file. (i.e. gulpfile.js)

cache( options )

This is the function you pass into your gulp chain which is returned from the exported function. This allows for configuration on a per stream basis. This function accepts the following options.

  • cascade (Boolean) -- This tells the caching engine whether each file in the file stream is individual. This means that the output of the stream is based on each individual file and not made of multiple files (i.e. no relation between files). For example, if one task concats multiple files into another single file, then one change to any of the files it concats together requires a whole new build. You would put cascade = true in this example because some files are dependant on other files and any changes made to the dependants are cascading. Conversely, if you had a task that simply transformed minified images, you would set cascade = false.

Events

The plugin emits two events to help you keep track of what's being cached.

cached

This event is emitted when a file in the stream hits the cache. It passes the path of the file that hit the cache.

cache-report

This event is emitted when the all the files have passed through the cache. It passes you an array of paths that hit the cache and never continues on the stream.

Caveats

Caching works by MD5'ing a file and comparing with the last known hash. It does not understand imports or require within files. I'd advise against using caching on any file that is an entry point to building other files. For example the entry file in browserify, if you make changes to some file the entry file requires and not the actual entry file, the task will not be run.

License & Author

Created and maintained by Adrian Cooney <[email protected]>

The MIT License (MIT)

Copyright (c) <2015> <Teamwork.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.