Created
December 19, 2013 20:49
-
-
Save christophercliff/8046040 to your computer and use it in GitHub Desktop.
How much code did you write compared to code installed with npm?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var stdin = process.openStdin() | |
var data = '' | |
stdin | |
.on('data', function(chunk) { | |
data += chunk | |
}) | |
.on('end', function(){ | |
parse(data) | |
}) | |
function parse(data) { | |
var mine = 0 | |
var theirs = 0 | |
var total = 0 | |
var length | |
data = JSON.parse(data) | |
for (var key in data) { | |
length = data[key].source.length | |
if (data[key].id.indexOf('node_modules') < 0) { | |
mine += length | |
} else { | |
theirs += length | |
} | |
total += length | |
} | |
console.log('mine: ' + percentify(mine, total) + '%, theirs: ' + percentify(theirs, total) + '%') | |
} | |
function percentify(val, total) { | |
return Math.round(val/total*100) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use with Browserify:
Outputs: