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

grunt-context

v0.3.3

Published

Give grunt some context, provide named configs for common options and override individual options via the command line

Readme

grunt-context

The aim of this plugin is to allow the grunt config to be overridden based on the current context selected. This is particularly useful if builds need to be tailored based upon the deployment environment.

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-context

Then add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-context');

Documentation

Usage

grunt-context supports arguments. The arguments are broken down as follows:

context:name:task:arguments

  • name: The name of the context to use
  • task: A single task or task list to run
  • arguments: The arguments to apply to a single task, these are ignored when a task list is used.

Overrides

Tasks you wish to provide a context for should be defined inside the context object and under the options key inside your main config. Properties for a specific task will then be combined with any defined outside of the context object.

Example grunt file with contexts defined:


// ... grunt file contents

    // =====================
    // GLOBAL CONFIG
    // =====================

    someplugin: {
        prop1: 'some original value',
        prop2: 'some original value'
    },

    context: {

        // =====================
        // CONFIG OVERRIDES
        // =====================

        development: {

            options: {

                someplugin: {
                    prop1: 'some development value',
                    prop3: 'some development value',
                    prop4: 'some development value'
                }

            },

            tasks: {
                'default': 'someplugin'
            }

        }

    }

// ... even more grunt file contents

The above configuration would result in the following config when grunt-context is run with the context set to "development".


    someplugin: {
        prop1: 'some development value',
        prop2: 'some original value'        
        prop3: 'some development value',
        prop4: 'some development value'
    },

Using the approach above you could also define the following tasks inside your grunt.js and when run the default task list for the context will run if it exists.


    grunt.registerTask('default', 'context:development');
    grunt.registerTask('release', 'context:production');

Tasks

Tasks can also be defined against a context, in the same way in which you would normally use grunt.registerTask you can now directly associate tasks to a specific context.


    tasks: {
        'default': 'someplugin'
    },

A "default" task should always be defined as per normal grunt task convention.

To run the default task for a context, this is possible using the following syntax:

> grunt context:development or
> grunt content:development:default

This will either run a single task or either a task list.

Note: Ensure that you do not duplicate task names.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

Release History

0.1.0

  • Initial Release

License

Copyright (c) 2012 "indieisaconcept" Jonathan Barnett
Licensed under the MIT license.