From b0abca0c3b58fac7ccd46cf386a398329858c2c0 Mon Sep 17 00:00:00 2001 From: Adam Kosecki Date: Mon, 14 Oct 2019 13:10:12 -0500 Subject: [PATCH 1/3] add ignore editor config --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3c3629e..34977ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.idea \ No newline at end of file From 8c1159434c395eb6a1d2e8b7ac107201edc59f86 Mon Sep 17 00:00:00 2001 From: Adam Kosecki Date: Mon, 14 Oct 2019 13:42:38 -0500 Subject: [PATCH 2/3] enable command line options --- index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) mode change 100644 => 100755 index.js diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 6d2eb1c..ffae11a --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ const exec = promisify(require('child_process').exec) const prompts = require('prompts') async function run () { - const { stdout: branches } = await exec('git branch -v --sort=-committerdate') + const { stdout: branches } = await exec(getGitBranchExecLine()) const choices = branches .split(/\n/) @@ -45,4 +45,18 @@ function onError (e) { } } +function getGitBranchExecLine() { + const argsAlwaysPresent = ['-v'] + + let args = process.argv.slice(2).reduce(function(carry, current) { + if (argsAlwaysPresent.indexOf(current) < 0) { + carry.push(current) + } + + return carry + }, []) + + return 'git branch ' + argsAlwaysPresent.concat(args).join(' ') +} + run().catch(onError) From 67843a6e07cda70280dc6b5d237928dbb8ee113a Mon Sep 17 00:00:00 2001 From: Adam Kosecki Date: Mon, 14 Oct 2019 15:20:40 -0500 Subject: [PATCH 3/3] better filter --- index.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index ffae11a..045b059 100755 --- a/index.js +++ b/index.js @@ -48,13 +48,9 @@ function onError (e) { function getGitBranchExecLine() { const argsAlwaysPresent = ['-v'] - let args = process.argv.slice(2).reduce(function(carry, current) { - if (argsAlwaysPresent.indexOf(current) < 0) { - carry.push(current) - } - - return carry - }, []) + let args = process.argv.slice(2).filter(function(current) { + return argsAlwaysPresent.indexOf(current) < 0; + }) return 'git branch ' + argsAlwaysPresent.concat(args).join(' ') }