SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const gitlog = require('gitlog');
  2. const {resolve} = require('path');
  3.  
  4. const changesToFiles = (opts = { repoPath: __dirname }) => {
  5.     const commitMap = gitlog({
  6.         repo: opts.repoPath
  7.         , number: opts.max || 1999999
  8.         , execOptions:
  9.             {
  10.                 maxBuffer: 99999 * 1024
  11.             }
  12.     }).map(c => c.files)
  13.         .reduce( (filesArray, files) => ([...filesArray, ...files]), [])
  14.         .sort()
  15.         .reduce((a, i) =>(( typeof a[i] === 'undefined' ? (a[i] = 1) : (a[i] = a[i] + 1) ) && a ), {});
  16.  
  17.     return Object.keys(commitMap)
  18.         .map(k => ([k, commitMap[k]]))
  19.         .sort((a, b) => (b[1] - a[1]))
  20.         .slice(0, opts.top || 100)
  21.         .reduce((a, i) => ((a[i[0]] = i[1]) && a), {});
  22. };
  23.  
  24. /*
  25. console.log(changesToFiles({
  26.     repoPath: resolve(__dirname, '../../react'),
  27.     top: 10
  28.     })
  29. );
  30. */
  31.  
  32. module.exports = changesToFiles;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top