tasks/patternprimer.js
function (patternFolder, cb) {
    // read pattern folder
    fs.readdir(patternFolder, function (err, contents) {
      // check for errors
      if (err !== null && err.code === 'ENOENT') {
        grunt.log.error('Cannot find patterns folder:', patternFolder);
        cb('Cannot find patterns folder: ' + patternFolder);
        return;
      }

      // list all pattern files (that end with .html)
      var files = [];
      contents.forEach(function (content) {
        if (content.substr(-5) === '.html') {
          files.push(content);
        }
      });
      // handle all the found pattern files
      handleFiles(patternFolder, files, cb);
    });
  }
function (patternFolder, cb) {
    // read pattern folder
    fs.readdir(patternFolder, function (err, contents) {
      // check for errors
      if (err !== null && err.code === 'ENOENT') {
        grunt.log.error('Cannot find patterns folder:', patternFolder);
        cb('Cannot find patterns folder: ' + patternFolder);
        return;
      }

      // list all pattern files (that end with .html)
      var files = [];
      contents.forEach(function (content) {
        if (content.substr(-5) === '.html') {
          files.push(content);
        }
      });
      // handle all the found pattern files
      handleFiles(patternFolder, files, cb);
    });
  }
function ( patternFolder , cb ) { // read pattern folder fs . readdir ( patternFolder , function ( err , contents ) { // check for errors if ( err !== null && err . code === 'ENOENT' ) { grunt . log . error ( 'Cannot find patterns folder:' , patternFolder ) ; cb ( 'Cannot find patterns folder: ' + patternFolder ) ; return ; } // list all pattern files (that end with .html) var files = [ ] ; contents . forEach ( function ( content ) { if ( content . substr ( - 5 ) === '.html' ) { files . push ( content ) ; } } ) ; // handle all the found pattern files handleFiles ( patternFolder , files , cb ) ; } ) ; }
reads all the patterns from the folder
reads all the patterns from the folder