Skip to content

Commit 6cace4b

Browse files
committed
[tools] Added basic lines of code tool
1 parent b95d2a0 commit 6cace4b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/tools/loc.coffee

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Lines of Code tool
2+
3+
util = require '../utils'
4+
eyes = require 'eyes'
5+
fs = require 'fs'
6+
7+
exports.exec = (options, callback) ->
8+
line_count = 0
9+
file_count = 0
10+
11+
# Cheating a bit for the async iteration here
12+
for glob in options._[1...]
13+
files = util.paths glob
14+
file_count += files.length
15+
16+
for glob in options._[1...]
17+
files = util.paths glob
18+
19+
files.forEach (v,i) ->
20+
fs.readFile v, (err, data) ->
21+
file_count = file_count - 1
22+
if err
23+
# throw err
24+
return
25+
line_count += data.toString().split('\n').length
26+
if file_count == 0
27+
callback(null, line_count);

0 commit comments

Comments
 (0)