From 267d6a89a8c2e1bbb8c854894f6072c86e0c9020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Thu, 28 May 2015 19:49:44 +0300 Subject: [PATCH] Parse the authors data --- lib/index.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index bf6615d..2be24e4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6,6 +6,7 @@ var Ul = require("ul") , Couleurs = require("couleurs")() , Gry = require("gry") , IsThere = require("is-there") + , CliPie = require("cli-pie") ; // Constants @@ -412,9 +413,30 @@ GitStats.authorsPie = function (options, callback) { return callback(new Error("Repository is missing.")); } - var repo = new Gry(options.repo); + var repo = new Gry(options.repo) + , pie = null + , pieData = [] + ; + repo.exec("shortlog -s -n --all", function (err, stdout) { if (err) { return callback(err); } - console.log(stdout); + lines = stdout.split("\n"); + + pieData = stdout.split("\n").map(function (c) { + var splits = c.split("\t").map(function (cc) { + return cc.trim(); + }); + return { + value: parseInt(splits[0]) + , label: splits[1] + }; + }); + + pie = new CliPie(20, pieData, { + legend: true + , flat: true + }); + + callback(null, pie.toString()); }); };