0.2.2 • Published 9 years ago

grunt-settings-changed v0.2.2

Weekly downloads
-
License
-
Repository
-
Last release
9 years ago

grunt-settings-changed

Triggers tasks when a settings object changes.

Getting Started

This plugin requires Grunt ~0.4.5

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-settings-changed --save-dev

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

grunt.loadNpmTasks('grunt-settings-changed');

The "settings_changed" task

Overview

In your project's Gruntfile, add a variable that contains the settings that need to be watched. Whenever one of these settings is changed, a task will be run.

Also, add a section named settings_changed to the data object passed into grunt.initConfig().

This works best in combination with grunt-contrib-watch, as shown in the example below.

// The settings object. Use this to add conditions to 
// the values in grunt.initConfig();.
var mySettings = {
  doSomething: true
}

grunt.initConfig({
  settings_changed: {
    options: {
      // Specify the settings object here.
      settings: mySettings, 

      "doSomething": ["task1", "task2"],
    },    
  },
});

Options

options.settings

Type: Object Default value: {}

The settings object. This is required.

options.taskname

Type: String[] Default value: []

The tasks to run when the setting with name 'taskname' is changed.

Usage Examples

Default Options

In this example, the rebuild task is called whenever the debug setting changes.

var mySettings = {
  debug: true
}

grunt.initConfig({
  settings_changed: {
    options: {
      settings: mySettings,
    },
    files: {
      'debug': ['rebuild'],
    },
  },
  watch : {
    grunt: { 
      files: ['gruntfile.js'],
      tasks: ['settings_changed']
    }, 
  }
});

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-settings-changed');
 
// simplified example 
grunt.registerTask('default', [ 'settings_changed', 'watch' ]);

## 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](http://gruntjs.com/).

## Release History
_(Nothing yet)_
0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago