helpers/GruntHelper.js
function generateGruntfile (generatedConfig) {
  return function(grunt) {
    var path = require('path'),
        fs = require('fs');

    require('load-grunt-tasks')(grunt);

    grunt.initConfig(generatedConfig);

    grunt.registerTask('default', ['watch']);

    // Handle new files with that have a new, supported preprocessor
    grunt.event.on('watch', function(action, filepath) {
      var ext = path.extname(filepath);

      // Ignore directories
      if (fs.lstatSync(filepath).isDirectory()) return;

      if (action === 'added') {
        // This is a special message that's parsed by YA
        // to determine if support for an additional preprocessor is necessary
        // Note: this allows us to avoid controlling grunt manually within YA
        console.log('EXTADDED:' + ext);

      // Note: we don't do anything for newly added .js files
      // A new js file can't be the root unless it's changed to require
      // the current root and saved/changed
      } else if (action === 'changed' || action === 'deleted') {
        if (ext === '.js') {
          // Ignore bundles
          if (/.+bundle.js/g.test(filepath)) return;

          // Notify YA to recompute the roots and
          // generate a configuration
          console.log('JSCHANGED:' + filepath);
        }
      }
    });

    // For watching entire directories but allowing
    // the grunt.event binding to take care of it
    grunt.registerTask('noop', function () {});
  };
}
function generateGruntfile (generatedConfig) {
  return function(grunt) {
    var path = require('path'),
        fs = require('fs');

    require('load-grunt-tasks')(grunt);

    grunt.initConfig(generatedConfig);

    grunt.registerTask('default', ['watch']);

    // Handle new files with that have a new, supported preprocessor
    grunt.event.on('watch', function(action, filepath) {
      var ext = path.extname(filepath);

      // Ignore directories
      if (fs.lstatSync(filepath).isDirectory()) return;

      if (action === 'added') {
        // This is a special message that's parsed by YA
        // to determine if support for an additional preprocessor is necessary
        // Note: this allows us to avoid controlling grunt manually within YA
        console.log('EXTADDED:' + ext);

      // Note: we don't do anything for newly added .js files
      // A new js file can't be the root unless it's changed to require
      // the current root and saved/changed
      } else if (action === 'changed' || action === 'deleted') {
        if (ext === '.js') {
          // Ignore bundles
          if (/.+bundle.js/g.test(filepath)) return;

          // Notify YA to recompute the roots and
          // generate a configuration
          console.log('JSCHANGED:' + filepath);
        }
      }
    });

    // For watching entire directories but allowing
    // the grunt.event binding to take care of it
    grunt.registerTask('noop', function () {});
  };
}
function generateGruntfile ( generatedConfig ) { return function ( grunt ) { var path = require ( 'path' ) , fs = require ( 'fs' ) ; require ( 'load-grunt-tasks' ) ( grunt ) ; grunt . initConfig ( generatedConfig ) ; grunt . registerTask ( 'default' , [ 'watch' ] ) ; // Handle new files with that have a new, supported preprocessor grunt . event . on ( 'watch' , function ( action , filepath ) { var ext = path . extname ( filepath ) ; // Ignore directories if ( fs . lstatSync ( filepath ) . isDirectory ( ) ) return ; if ( action === 'added' ) { // This is a special message that's parsed by YA // to determine if support for an additional preprocessor is necessary // Note: this allows us to avoid controlling grunt manually within YA console . log ( 'EXTADDED:' + ext ) ; // Note: we don't do anything for newly added .js files // A new js file can't be the root unless it's changed to require // the current root and saved/changed } else if ( action === 'changed' || action === 'deleted' ) { if ( ext === '.js' ) { // Ignore bundles if ( / .+bundle.js / g . test ( filepath ) ) return ; // Notify YA to recompute the roots and // generate a configuration console . log ( 'JSCHANGED:' + filepath ) ; } } } ) ; // For watching entire directories but allowing // the grunt.event binding to take care of it grunt . registerTask ( 'noop' , function ( ) { } ) ; } ; }
Helper that returns a function whose body represents a gruntfile definition
Helper that returns a function whose body represents a gruntfile definition