title: In Gulp, how do I only run a task on one file if any of multiple files are newer?
body: <p>I'm probably trying to make gulp do something that's not idiomatic, but here goes.
  I want my build task to only run if the source files are newer than the output file.</p>
  
  <p>In gulp, it seems standard practice to create a build task that always runs, and then set up a watch task to only run that build task when certain files change. That's okay, but it means that you <em>always</em> build on the first run.</p>
  
  <p>So, is it possible to do what I want? Here's what I've got so far (newer is gulp-newer):</p>
  
  <pre><code>gulp.task('build_lib', function() {
  
  return gulp.src(["app/**/*.ts"])
      .pipe(newer("out/outputLib.js")) //are any of these files newer than the output?
  
   ** NEED SOMETHING HERE **
     how do I say, "If I got _any_ files from the step before, replace all of them with a single hardcoded file "app/scripts/LibSource.ts" "?
  
      .pipe(typescript({
          declaration: true,
          sourcemap: true,
          emitError: false,
          safe: true,
          target: "ES5",
          out: "outputLib.js"
      }))
      .pipe(gulp.dest('out/'))
  </code></pre>
  
  <p>});</p>
  
  <p>I tried using gulpif, but it doesn't seem to work if there are no files going into it to begin with. </p>
  
  <pre><code>    .pipe(gulpif(are_there_any_files_at_all,
          gulp.src(["app/scripts/LibSource.ts"])))
  </code></pre>
  
  <p>However, my condition function isn't even called because there are no files on which to call it. gulpif calls the truthy stream in this case, so LibSource gets added to my stream, which isn't what I want. </p>
  
  <p>Maybe doing all of this in a single stream really isn't the right call, since the only reason I'm passing those files through the "gulp-newer" filter is to see if any of them is newer. I'm then discarding them and replacing them with another file. My question still stands though. </p>