Browse files

Silent failure if git command line not found. Fixes #4

  • Loading branch information...
1 parent 37380da commit 662cb91b71d43fb2d1b43a63495602553d97e5ee @rdworth committed with rwaldron Apr 25, 2012
Showing with 14 additions and 1 deletion.
  1. +1 −1 package.json
  2. +13 −0 tasks/compare-size.js
View
2 package.json
@@ -1,7 +1,7 @@
{
"name": "grunt-compare-size",
"description": "Compare file sizes on this branch to master",
- "version": "0.1.5",
+ "version": "0.1.6",
"homepage": "https://github.com/rwldrn/grunt-compare-size",
"author": {
"name": "Rick Waldron <waldron.rick@gmail.com>",
View
13 tasks/compare-size.js
@@ -58,6 +58,11 @@ module.exports = function(grunt) {
// Obtain the current branch and continue...
grunt.helper( "git_current_branch", function( err, branch ) {
var key, diff, color;
+
+ if ( err ) {
+ grunt.log.error( err );
+ return false;
+ }
// Derived and adapted from Corey Frang's original `sizer`
grunt.log.writeln( "Sizes - compared to master" );
@@ -106,15 +111,23 @@ module.exports = function(grunt) {
});
grunt.registerHelper( "git_current_branch", function(done) {
+ grunt.verbose.write( "Running `git branch` command..." );
grunt.utils.spawn({
cmd: "git",
args: [ "branch", "--no-color" ]
}, function(err, result) {
var branch;
+ if ( err ) {
+ grunt.verbose.error();
+ done( err );
+ return;
+ }
+
result.split("\n").forEach(function(branch) {
var matches = /^\* (.*)/.exec( branch );
if ( matches != null && matches.length && matches[ 1 ] ) {
+ grunt.verbose.ok();
done( null, matches[ 1 ] );
}
});

0 comments on commit 662cb91

Please sign in to comment.