Skip to content

Commit

Permalink
Added more exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bchabrier committed Jun 5, 2016
1 parent 23fb4b5 commit cefdd3a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/fixtures/tasks/simplecopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ module.exports = function(grunt) {
var src = this.data.src;
var dest = this.data.dest;
var done = this.async();

var rd = fs.createReadStream(src);
rd.on("error", function(err) {
grunt.fail.fatal(err);
done();
});
var wr = fs.createWriteStream(dest);
wr.on("error", function(err) {
grunt.fail.fatal(err);
done();
});
wr.on("close", function(ex) {
grunt.log.writeln('Copied ' + src + ' to ' + dest + '.');
if (ex) {
grunt.fail.fatal(ex);
} else {
grunt.log.writeln('Copied ' + src + ' to ' + dest + '.');
}
done();
});
rd.pipe(wr);
Expand Down

0 comments on commit cefdd3a

Please sign in to comment.