-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
26 lines (23 loc) · 853 Bytes
/
main.js
File metadata and controls
26 lines (23 loc) · 853 Bytes
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
#!/usr/bin/env node
const exec = require('child_process').exec;
const tree = require('./src/tree');
const diffStrToChanges = require('./src/diffStrToChanges');
const drawTree = require('./src/drawTree');
const print = require('./src/print');
const execDiffandDrawTree = (branchB) => {
exec(`git diff --name-status --no-renames ${diffAgainstBranch}...${branchB}`, (err, stdout, stderr) => {
const changes = diffStrToChanges(stdout);
const treeData = tree(changes);
console.log(drawTree(treeData));
});
};
const diffAgainstBranch = process.argv[2] || 'master';
if (process.argv[3] === undefined) {
exec('git symbolic-ref --short HEAD', (err, stdout, stderr) => {
const checkedOutBranch = stdout.trim();
execDiffandDrawTree(checkedOutBranch);
});
} else {
const branchB = process.argv[3];
execDiffandDrawTree(branchB);
}