lib/index.js
function status() {
  var tasks = [],
      cwd = process.cwd();

  findRepos(function(err, repos) {
    if (err) return console.log(err);
    repos.forEach(function(repo) {
      tasks.push(function(done) {
        repo.status(function(err, status) {
          if (err) return done(err);
          if (argv.b) {
            repo.branch(function(err, head) {
              if (err) return done(err);
              done(null, {status: status, head: head});
            });
          }
          else {
            done(null, {status: status});
          }
        });
      });
    });
    async.series(tasks, function(err, results) {
      if (err) return console.log(err);

      var row,
          col,
          res,
          file,
          head = [],
          table,
          symbol;

      head.push('Repo');
      if (argv.b) {
        head.push('Branch');
      }
      head.push('Status');

      table = new Table({
        head: head,
        style: {
          compact: true,
          'padding-left': 1,
          'padding-right': 1,
          head: ['white', 'bold']
        }
      });

      results.forEach(function(res) {
        var row = [];

        row.push(res.status.repo.path.replace(cwd + '/', ''));
        if (argv.b) {
          row.push(res.head.name);
        }
        row.push(res.status.clean ? 'Clean'.green : 'Changed'.red);
        table.push(row);

        if (argv.v) {
          for (var name in res.status.files) {
            row = [];
            row.push('');
            if (argv.b) {
              row.push('');
            }
            switch (res.status.files[name].type) {
              case 'A':
                symbol = '+'.green; break;
              case 'D':
                symbol = '-'.red; break;
              case 'M':
                symbol = '*'.yellow; break;
              default:
                symbol = '~'.grey; break;
            }
            row.push(' ' + symbol + ' ' + name);
            table.push(row);
          }
        }
      });

      console.log(table.toString());
    });
  });
}
function status() {
  var tasks = [],
      cwd = process.cwd();

  findRepos(function(err, repos) {
    if (err) return console.log(err);
    repos.forEach(function(repo) {
      tasks.push(function(done) {
        repo.status(function(err, status) {
          if (err) return done(err);
          if (argv.b) {
            repo.branch(function(err, head) {
              if (err) return done(err);
              done(null, {status: status, head: head});
            });
          }
          else {
            done(null, {status: status});
          }
        });
      });
    });
    async.series(tasks, function(err, results) {
      if (err) return console.log(err);

      var row,
          col,
          res,
          file,
          head = [],
          table,
          symbol;

      head.push('Repo');
      if (argv.b) {
        head.push('Branch');
      }
      head.push('Status');

      table = new Table({
        head: head,
        style: {
          compact: true,
          'padding-left': 1,
          'padding-right': 1,
          head: ['white', 'bold']
        }
      });

      results.forEach(function(res) {
        var row = [];

        row.push(res.status.repo.path.replace(cwd + '/', ''));
        if (argv.b) {
          row.push(res.head.name);
        }
        row.push(res.status.clean ? 'Clean'.green : 'Changed'.red);
        table.push(row);

        if (argv.v) {
          for (var name in res.status.files) {
            row = [];
            row.push('');
            if (argv.b) {
              row.push('');
            }
            switch (res.status.files[name].type) {
              case 'A':
                symbol = '+'.green; break;
              case 'D':
                symbol = '-'.red; break;
              case 'M':
                symbol = '*'.yellow; break;
              default:
                symbol = '~'.grey; break;
            }
            row.push(' ' + symbol + ' ' + name);
            table.push(row);
          }
        }
      });

      console.log(table.toString());
    });
  });
}
function status ( ) { var tasks = [ ] , cwd = process . cwd ( ) ; findRepos ( function ( err , repos ) { if ( err ) return console . log ( err ) ; repos . forEach ( function ( repo ) { tasks . push ( function ( done ) { repo . status ( function ( err , status ) { if ( err ) return done ( err ) ; if ( argv . b ) { repo . branch ( function ( err , head ) { if ( err ) return done ( err ) ; done ( null , { status : status , head : head } ) ; } ) ; } else { done ( null , { status : status } ) ; } } ) ; } ) ; } ) ; async . series ( tasks , function ( err , results ) { if ( err ) return console . log ( err ) ; var row , col , res , file , head = [ ] , table , symbol ; head . push ( 'Repo' ) ; if ( argv . b ) { head . push ( 'Branch' ) ; } head . push ( 'Status' ) ; table = new Table ( { head : head , style : { compact : true , 'padding-left' : 1 , 'padding-right' : 1 , head : [ 'white' , 'bold' ] } } ) ; results . forEach ( function ( res ) { var row = [ ] ; row . push ( res . status . repo . path . replace ( cwd + '/' , '' ) ) ; if ( argv . b ) { row . push ( res . head . name ) ; } row . push ( res . status . clean ? 'Clean' . green : 'Changed' . red ) ; table . push ( row ) ; if ( argv . v ) { for ( var name in res . status . files ) { row = [ ] ; row . push ( '' ) ; if ( argv . b ) { row . push ( '' ) ; } switch ( res . status . files [ name ] . type ) { case 'A' : symbol = '+' . green ; break ; case 'D' : symbol = '-' . red ; break ; case 'M' : symbol = '*' . yellow ; break ; default : symbol = '~' . grey ; break ; } row . push ( ' ' + symbol + ' ' + name ) ; table . push ( row ) ; } } } ) ; console . log ( table . toString ( ) ) ; } ) ; } ) ; }
Output the status of found git repositories.
Output the status of found git repositories .