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

v0.2.3

Published

Helpers to load and use recursive Gruntfiles.

Downloads

924

Readme

grunt-recurse

Recursively load subproject Grunt files. Load all grunt-* modules saved in package.json's dependency lists. All you need to do is define config options and register your own tasks.

Basic Usage

In a Gruntfile in the root of your project, require grunt-recurse and tell it to load subprojects. Register any default tasks and configurations. Finalize the grunt configuration.

// ./Gruntfile.js

module.exports = function(grunt){

    // Use grunt-recurse on the module. Pass the __dirname to ensure pathing.
    require('grunt-recurse')(grunt, __dirname);
    [
        './src/client',
        './src/server'
    ].each(function(subproject){
        grunt.grunt(subproject);
    });

    // Prepare any multiconfigs.
    grunt.Config = {
        jshint: {
            files: ['./src/**/*.js'],
            options: {
                jshintrc: './.jshintrc'
            }
        }
    };

    // Register tasks like normal.
    grunt.registerTask(
        'default', 
        'Perform full build and test of the entire project.'
        [ 'jshint', 'client', 'server' ]
    );

    // Call finalize to push grunt.Config into initConfg, and other things.
    grunt.finalize();
};

In the Gruntfiles of each subproject, assign config setting to grunt.Config. File paths will still be relative to the root Gruntfile.

// ./src/client/Gruntfile.js
module.exports = function(grunt){
    grunt.Config = {
        copy: {
            client: {
                files: [ {
                    expand: true,
                    src: ['./src/client/**'],
                    dest: './build/client'
                } ]
            }
        }
    };

    grunt.registerTask(
        'client',
        'Perform all tasks necessary to build the client.'
        ['copy:client']
    );
};

Automagic

grunt-recurse uses sindresorhus/load-grunt-tasks to mitigate need for grunt.loadNpmTasks or grunt.NpmTasks = []. package.json settings are loaded into grunt.pkg.

Conventions

There are no enforcements on task naming or configuration settings. Grunt will apply whatever change got made last during the run. Thus, grunt.registerTask with the same name in both the core Gruntfile and the submodule Gruntfile will conflict, and (using the above code layout) the core Gruntfile's definition will be used.

For this reason, I recommend the convention of each submodule Gruntfile registering a task with the name of the submodule's folder, and namespacing the registered tasks within the submodule as camel-case or hyphen-seperated using the submodule's folder name. This is just a convention, and you are free to use whatever mechanism necessary to ensure the tasks names do not collide.

The config object is merged at the task level. Using, eg, grunt-contrib-copy across several modules, if each target is given a seperate name, they will live harmoniously. Otherwise, the last defined target options will override any prior definitions.

Changelog

0.2.1 on 2013-12-22

  • No longer warns that grunt-recurse isn't a loadable grunt task.

0.2.0 on 2013-11-17

  • load-grunt-tasks to load all npm tasks saved in package.json
  • Remove coffee-script dependency.
  • Automatically finalize Grunt configuration.
  • Updated documentation.

0.1.0 on 2013-10-29

  • grunt.grunt to load submodule grunt files.
  • grunt.Config = {configobject} to set task config properties.