Skip to content

Instantly share code, notes, and snippets.

@natural-affinity
Created February 6, 2015 18:22
Show Gist options
  • Select an option

  • Save natural-affinity/cdbe227ab8a849a4fa0e to your computer and use it in GitHub Desktop.

Select an option

Save natural-affinity/cdbe227ab8a849a4fa0e to your computer and use it in GitHub Desktop.
Run sub-task conditionally, based on JSON meta-data
module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    client: grunt.file.readJSON('client.json')
  });

  grunt.registerTask('conditional-task', []);

  //reads config file and builds according to metadata flag
  grunt.registerTask('build:faq', function () {
    var hasFaq = grunt.config.data.client.hasFaq;
    if (hasFaq === true) {
      grunt.task.run(['conditional-task']);
    }
  });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment