title: Gulp-rev: isn't working at the first time, but after it
body: <p>I'm having an error, but don't know why it happens. In the following code I build css files. The task "build-single-styles" (in runSequence) builds temporary css-files. The second task concatenates every css file with two other files and writes them in the same folder one level deeper, into "/concat".</p>
  
  <p>The last function should build a json-file</p>
  
  <pre><code>{
    "base.css": "base-zt121112fd.css,
    ...
  }
  </code></pre>
  
  <p>which holds key-value pairs, that I can integrate the hashed css-files into the different templates. It's fired when all css-files are written into the "/concat"-folder.</p>
  
  <pre><code>var runSequence = require('run-sequence');
  var concat = require('gulp-concat');
  var rev = require('gulp-rev');
  
  //run single tasks in a row
  gulp.task('build-styles', function(){
    runSequence('build-single-styles', 'concat-styles');
  });
  
  //build styles
  gulp.task('build-single-styles', function() {
    return gulp.src(allStyles)
      .pipe($.plumber({ errorHandler: function (error) {}}))
      .pipe($.rubySass({
          style: sassStyle,
          compass: true,
          noCache: true
      }))
      .pipe(isProduction ? $.combineMediaQueries({ log: true }) : _.noop())
      .pipe(isProduction ? $.minifyCss({ keepSpecialComments: 1 }) : _.noop())
      .pipe($.plumber.stop())
      .pipe(gulp.dest(paths.styles.destTemp))
      .pipe($.size({
          showFiles: true
      }))
  });
  
  //concat each css with 2 others
  gulp.task('concat-styles', function(){
    var files = fs.readdirSync(paths.styles.destTemp);
    var index = files.indexOf('slider.css');
  
    if(index &gt; -1) files.splice(index, 1);
  
    var autosuggest = paths.styles.srcBase + '/autosuggest_inquisitor.css';
  
    for(var i = 0; i &lt; files.length; i++) {
      gulp.src([paths.styles.destTemp + '/' + files[i], autosuggest, paths.styles.destTemp + '/slider.css'])
          .pipe($.concat({path: files[i], cwd: ''}))
          .pipe(gulp.dest(paths.styles.destTemp + '/concat'));
  
      if(i == files.length - 1) buildManifest();
  }
  });
  
  function buildManifest(){
    gulp.src([paths.styles.destTemp + '/concat/*.css', !paths.styles.destTemp + '/concat/slider.css'])
      .pipe(rev())
      .pipe(gulp.dest(paths.styles.dest))
      .pipe(rev.manifest({ base: styleLinkup, path: 'styles-linkup.json' }))
      .pipe(gulp.dest(styleLinkup));
  }
  </code></pre>
  
  <p>When i run "gulp build-styles" the first time the function "buildManifest" fires correct, but nothing is written, as if it doesn't find the src-folder. If I run it twice it works. The rev'd files are written and so the json-file. Any assumptions?</p>
  
  <p>Greetings,
  Lars</p>
  
  <p><strong>Edit 1:</strong> Making a task out of the function "buildManifest" and run it alone after building the final css-files also works. But it's not working when putting the task into the sequence.</p>
  
  <p><strong>Edit 2:</strong> I tried sth. else inside the buildManifest function:</p>
  
  <pre><code>var concatFiles = fs.readdirSync(paths.styles.destTemp + '/concat');
  console.log(concatFiles);
  </code></pre>
  
  <p>Now I get an error on "fs.readdirSync(paths.styles.destTemp + '/concat');" and it says the following:</p>
  
  <p>Error: ENOENT, no such file or directory './web/assets/css/temp/concat'.</p>
  
  <p>Seems like the folder which I create before isn't detected right after its creation.</p>