title: gulp: blanking output if Browserify fails
body: <p>I'm using Browserify in my <code>gulpfile.js</code> like so:</p>
  
  <pre><code>browserify("src/main.js").bundle()
      .on("end", function() {
          console.log("compiled JavaScript via Browserify");
      })
      .on("error", function(err) {
          console.warn("ERROR: Browserify failed", err);
      })
      .pipe(source("bundle.js"))
      .pipe(gulp.dest("./dist"));
  </code></pre>
  
  <p>However, it's easy to miss compilation errors - so I'd prefer to blank <code>dist/bundle.js</code> (or insert an <code>alert("ERROR");</code>) instead of just reporting errors in the terminal.</p>
  
  <p>My attempts to implement this failed due to what I assume is a race condition (pipe conclusion overwriting file operations in the "error" event handler), so I'd be grateful for some advice on how to do this properly.</p>