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

v0.1.4

Published

Automatically fill in grunt-contrib-watch configuration 'task' and 'files' properties.

Downloads

4

Readme

grunt-autowatch

NPM version Build Status Build Status

This plugin supplies default tasks and files to grunt-contrib-watch listeners that don't have them.

If a watch listener has no tasks property, it is given a task that matches its name. For example, a watcher named jade will receive a tasks of ['jade'].

If a watch listener has no files property, it is given the files from the configurations for those of its tasks that are plugins. For example, a watcher whose tasks are equal to ['jade'] will receive a files list that is constructed from the jade plugin configuration, transfomed into a format that grunt-contrib-watch can understand.

Together, these defaults allow one to write e.g.

grunt.initConfig({
  watch: {
    coffee: {},
    jade: {}
  }
})

to do the equivalent of

grunt.initConfig({
  watch: {
    coffee: {tasks: ['coffee'], files: 'app/**/*.coffee'},
    jade: {tasks: ['jade'], files: 'app/**/*.jade'}
  }
})

where the actual values of the files property are copied from the configurations of their respective plugins, with cwd properties applied to the paths, and with the various grunt formats for specifying files normalized into a single list of file pattern strings so that watch can understand them.

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-autowatch --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-autowatch');

The "autowatch" task

No configuration for autowatch itself is necessary.

Run this task with the grunt autowatch command. With the default options, this modifies the watch configuration, and then runs watch.

Options

options.run

Type: Boolean Default value: true

If true, grunt autowatch runs the watch task after modifying the watch configuration.

options.tasks

Type: Array Default value: []

This is a list of plugin or plugin:target strings. grunt autowatch inserts watcher configurations for these tasks into the watch configuration.

Usage Examples

The following example contains stubs for coffee and jade watchers inside the watch configuration. grunt autowatch task sets the watch.coffee.task and watch.jade.task to ['coffee'] and ['jade'] respecively (based on name of the watcher), and sets watch.coffee.files and watch.jade.files to a list of file patterns based on the coffee and jade configurations.

grunt.initConfig({
  coffee: { ... },
  jade: { ... },
  watch: {
    coffee: {},
    jade: {}
  }
})

The following example defines a watcher with a configured list of tasks, but omit the files properties. grunt autowatch sets watch.grunt.files to a list of file patterns based on the gruntfile target of the coffeelint plugin configuration.

grunt.initConfig({
  coffeelint: {gruntfile: {...}},
  watch: {
    grunt: {tasks: ['coffeelint:gruntfile']}
  }
})

The following configuration omits watchers for coffee and jade entirely. grunt autowatch inserts watchers for these tasks into the watch configuration.

grunt.initConfig({
  coffee: { ... },
  jade: { ... },
  autowatch: {
    options:
      tasks: ['coffee', 'jade']
  },
})

The following autowatch configuration configures autowatch to only modify the watch configuration -- and not to run the watch task when it is done. With this option, grunt autowatch watch is necessary in order to run the watchers.

grunt.initConfig({
  autowatch: {
    options:
      run: false
  },
})

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

  • September 26, 20012 -- initial release