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

grunt-if-missing

v1.0.1

Published

Conditionally run Grunt tasks if the destination is missing.

Downloads

602

Readme

grunt-if-missing

Conditionally run a task if any of its destination files do not exist.

NPM Build Status Dependencies Dev Dependencies

Why?

I used grunt-curl to download an external dependency. That task would get executed often, but the file did not need to get downloaded again if it already existed. With this plugin I am able to execute a task if it is currently missing its "dest" file.

Another project uses a git submodule as a dependency and needs to build it once before using it. This plugin is able to determine if a file exists and will use grunt-run to start a build that will generate the necessary files. Once they exist they won't need to get rebuilt.

Usage

This plugin requires Grunt ~0.4.1. If you have not used Grunt before, make sure to read its Getting Started guide to learn about gruntfile.js and installing plugins.

Installation is easy and identical to other plugins:

npm install grunt-if-missing --save-dev

Once installed, you might have it loaded automatically if you use load-grunt-tasks, or you can manually load it with this line:

grunt.loadNpmTasks('grunt-if-missing');

Configuration

There is no special configuration necessary. Like the newer plugin, you will just add if-missing as the first argument when running other tasks. Let's use a configuration that uses grunt-curl as an example.

grunt.initConfig({
    curl: {
        angular: {
            dest: "3rd_party/angular-1.2.14.zip",
            src: "http://code.angularjs.org/1.2.14/angular-1.2.14.zip"
        }
    }
});
grunt.loadNpmTasks('grunt-curl');
grunt.loadNpmTasks('grunt-if-missing');
grunt.registerTask('get-dependencies', [
    'if-missing:curl:angular'
]);

By using just this configuration, you can now download your Angular dependency by issuing grunt curl. It would normally download it every time, even if it already existed. grunt get-dependencies will download the file only if it does not already exist at 3rd_party/angular-1.2.14.zip.

This task is only able to be used with other tasks that have dest defined or specify a destination filename in any of the standard methods.

Development

If you want to work on this library, you need to check out the repository and run npm install to get the dependencies.

Tests are always included. Make sure tests cover your changes. To run the current tests, just use npm test or grunt test (they will run the same test suite).

License

This software is licensed under an MIT license with an additional non-advertising clause.