This commit is contained in:
rkiel
2019-07-14 22:04:17 -04:00
parent 4c4a16af04
commit 604d3d84c4
4 changed files with 85 additions and 24 deletions

20
js/commander.js Normal file
View File

@@ -0,0 +1,20 @@
const commander = require("commander");
const program = new commander.Command();
const something = program.parse(process.argv);
let lib;
function parse() {
return something;
}
function args() {
return something.args;
}
lib = {
args,
parse
};
module.exports = lib;

19
js/git.js Normal file
View File

@@ -0,0 +1,19 @@
const _ = require("lodash");
const path = x => require("../" + x);
const immutable = path("js/immutable");
const shell = path("js/shell");
let lib;
function setCurrentBranch(dp) {
const cmd = "git rev-parse --abbrev-ref HEAD";
return shell.capture(cmd).then(x => immutable.set(dp, "currentBranch", x));
}
lib = {
setCurrentBranch
};
module.exports = lib;

33
js/shell.js Normal file
View File

@@ -0,0 +1,33 @@
const _ = require("lodash");
const util = require("util");
const child_process = require("child_process");
const exec = util.promisify(child_process.exec);
let lib;
function run(cmd) {
return exec(cmd);
}
function capture(cmd) {
return lib.run(cmd).then(x => x.stdout.trim());
}
function _something(dp) {
return function() {
return dp;
};
}
function something(cmd, dp) {
return lib.run(cmd).then(lib._something(dp));
}
lib = {
_something,
run,
capture,
something: _.curry(something)
};
module.exports = lib;