code: function fetchCommit(dir, len){
    if (!len)
      len = 10;
  
    try {
      var gitPath = dir + '/.git/';
      var gitRef = fs.readFileSync(gitPath + 'HEAD', 'utf-8');
      if (gitRef)
      {
        var ref = gitRef.match(/(?:^|\n)ref:\s*([^\n]+)/);
        if (ref)
          return fs.readFileSync(gitPath + ref[1], 'utf-8').substr(0, len);
      }
    } catch(e) {}
  
    try {
      return require(dir + '/.bower.json')._resolution.commit.substr(0, len);
    } catch(e){}
  }
docs: Trying get a commit hash for specified folder (supposed a git repo or bower library).
  @param {string} dir Location for lookup
  @param {number=} len Max length of hash