all files / src/commitizen/ staging.js

100% Statements 2/2
100% Branches 5/5
100% Functions 2/2
100% Lines 2/2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20                                   
import {exec} from 'child_process';
 
export {isClean};
 
/**
 * Asynchrounously determines if the staging area is clean
 */
function isClean(repoPath, done) {
  exec('git diff --cached --name-only', {
    maxBuffer: Infinity,
    cwd: repoPath || process.cwd()
  }, function(error, stdout) {
    if (error) {
      return done(error);
    }
    let output = stdout || '';
    done(null, output.trim().length === 0);
  });
}