Skip to content

Commit

Permalink
Added option to ignore errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhasselrot committed Nov 14, 2013
1 parent c6ecd98 commit 2ed256c
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions tasks/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = function(grunt) {
var done = grunt.task.current.async();
var options = this.options({
extension: 'js',
ignoreErrors: false,
ignoreMTime: false
});

Expand Down Expand Up @@ -62,13 +63,22 @@ module.exports = function(grunt) {

grunt.log.writeln("[react] "+srcFile+" --> "+destFile);

var src = fs.readFileSync(srcFile).toString();
var newSrc = transform(src);
var destDir = path.dirname(destFile);

mkdirp.sync(destDir);

fs.writeFileSync(destFile, newSrc);
var src = fs.readFileSync(srcFile).toString();

try {
var newSrc = transform(src);
var destDir = path.dirname(destFile);
mkdirp.sync(destDir);
fs.writeFileSync(destFile, newSrc);
} catch (e) {
if (options.ignoreErrors) {
var error = grunt.log.wordlist(['[react] ' + e], {color: 'red'});
grunt.log.error(error);
} else {
throw e;
}
}

});
done();
});
Expand Down

0 comments on commit 2ed256c

Please sign in to comment.