tasks/patternprimer.js
function (cb) {
    // check if we have a custom index file set
    if (settings.index) {
      // generate the real index file path
      var indexFile = process.cwd() + '/' + settings.index;

      // check if the file exists, throw an error otherwise
      if (!grunt.file.exists(indexFile)) {
        grunt.log.error('Index file: "' + indexFile + '" not found');
        cb('Index file: "' + indexFile + '" not found');
        return;
      }

      // load the file contents
      sourceFile = grunt.file.read(indexFile);
    }

    // modify the sourcefile css according to the settings
    var css = settings.css.map(function (file) {   
      if (settings.snapshot && file.search('http://') !== -1) {
        return '<link rel="stylesheet" type="text/css" href="' + path.basename(file) + '"/>';
      } else {
        return '<link rel="stylesheet" type="text/css" href="' + file + '"/>';
      }
    });
    sourceFile = sourceFile.replace('{{css}}', css.join(''));

    // spit out the default sourcefile
    cb(sourceFile);
  }
function (cb) {
    // check if we have a custom index file set
    if (settings.index) {
      // generate the real index file path
      var indexFile = process.cwd() + '/' + settings.index;

      // check if the file exists, throw an error otherwise
      if (!grunt.file.exists(indexFile)) {
        grunt.log.error('Index file: "' + indexFile + '" not found');
        cb('Index file: "' + indexFile + '" not found');
        return;
      }

      // load the file contents
      sourceFile = grunt.file.read(indexFile);
    }

    // modify the sourcefile css according to the settings
    var css = settings.css.map(function (file) {   
      if (settings.snapshot && file.search('http://') !== -1) {
        return '<link rel="stylesheet" type="text/css" href="' + path.basename(file) + '"/>';
      } else {
        return '<link rel="stylesheet" type="text/css" href="' + file + '"/>';
      }
    });
    sourceFile = sourceFile.replace('{{css}}', css.join(''));

    // spit out the default sourcefile
    cb(sourceFile);
  }
function ( cb ) { // check if we have a custom index file set if ( settings . index ) { // generate the real index file path var indexFile = process . cwd ( ) + '/' + settings . index ; // check if the file exists, throw an error otherwise if ( ! grunt . file . exists ( indexFile ) ) { grunt . log . error ( 'Index file: "' + indexFile + '" not found' ) ; cb ( 'Index file: "' + indexFile + '" not found' ) ; return ; } // load the file contents sourceFile = grunt . file . read ( indexFile ) ; } // modify the sourcefile css according to the settings var css = settings . css . map ( function ( file ) { if ( settings . snapshot && file . search ( 'http://' ) !== - 1 ) { return '<link rel="stylesheet" type="text/css" href="' + path . basename ( file ) + '"/>' ; } else { return '<link rel="stylesheet" type="text/css" href="' + file + '"/>' ; } } ) ; sourceFile = sourceFile . replace ( '{{css}}' , css . join ( '' ) ) ; // spit out the default sourcefile cb ( sourceFile ) ; }
gets the user defined source file, or uses the default one
gets the user defined source file or uses the default one