-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
52 lines (44 loc) · 1.25 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// log files generated by
//
// git log --name-only --pretty=format:""
//
// NOTE: use git-also.js if you wan to run this in the git repository
var readline = require('readline');
var fs = require('fs');
var computeSimilarities = require('./lib/computeSimilarities.js');
var startShell = require('./lib/startShell.js');
var inputFileName = process.argv[2];
if (!fs.existsSync(inputFileName)) {
console.log('Cannot find input file.');
console.log('');
console.log('To create input file, run the following command: ');
console.log('');
console.log('git log --name-only --pretty=format:"" > inputFile.log');
console.log('');
console.log('Then re-run this program: ');
console.log('');
console.log('node index.js inputFile.log');
process.exit(1)
}
console.log('reading file: ' + inputFileName);
var rl = readline.createInterface({
input: fs.createReadStream(inputFileName)
});
var buffer = [];
var commits = [];
rl.on('line', processLine);
rl.on('close', startInteractiveShell);
function processLine(line) {
if (line) {
buffer.push(line)
} else {
if (buffer.length > 0) {
commits.push(buffer);
buffer = [];
}
}
}
function startInteractiveShell() {
var similarities = computeSimilarities(commits)
startShell(similarities);
}