Skip to content

Commit f98ea44

Browse files
committed
Add some meta to templates as well as change the arguments
* use `commit-with -a` to mimic `git commit -a` * use `commit-with -f` to force a user search and cache bust for the given user Co-Authored-By: Eric Adamski <er.adamski@gmail.com>
1 parent 49ce40e commit f98ea44

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

index.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const program = require('commander');
33
const { merge } = require('rxjs/observable/merge');
44
const { switchMap, partition } = require('rxjs/operators');
55

6+
const { VERSION } = require('./src/constants');
67
const commit = require('./src/commit');
78
const {
89
createCommitTemplate,
@@ -11,20 +12,30 @@ const {
1112
const search = require('./src/search');
1213

1314
program
14-
.version('0.1.0')
15+
.version(VERSION)
1516
.name('commit-with')
16-
.arguments('<github-username> -- [git-args...]')
17+
.option('-a, --all', 'commit all changed files')
18+
.option(
19+
'-f, --force',
20+
'ignore cached commit templates, look up user again on githup'
21+
)
22+
.arguments('<github-username>')
1723
.description(
1824
'Searches Github for the user and auto generates a co-authored tag for your commit message'
1925
)
2026
.parse(process.argv);
2127

2228
const username = program.args[0];
23-
const args = program.args.slice(1);
29+
const args = [program.all && '-a'].filter(v => v);
2430
const cwd = process.cwd();
2531

32+
if (!username) {
33+
program.help();
34+
process.exit(1);
35+
}
36+
2637
const [filepath$, noFilepath$] = getCommitTemplateFor(username).pipe(
27-
partition(filepath => filepath)
38+
partition(filepath => filepath && !program.force)
2839
);
2940

3041
merge(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "commit-with",
3-
"version": "0.2.1",
3+
"version": "0.3.1",
44
"scripts": {
55
"test": "jest"
66
},

src/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ const { homedir } = require('os');
33

44
module.exports = {
55
GITHUB_URL: 'https://api.github.com',
6-
TEMPLATE_ROOT: join(homedir(), '.co-author-commit-templates')
6+
TEMPLATE_ROOT: join(homedir(), '.co-author-commit-templates'),
7+
VERSION: 'v0.3.1'
78
};

src/create-commit-template.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { of } = require('rxjs/observable/of');
55
const { bindNodeCallback } = require('rxjs/observable/bindNodeCallback');
66
const { catchError, switchMap, mapTo, map } = require('rxjs/operators');
77

8-
const { TEMPLATE_ROOT } = require('./constants');
8+
const { TEMPLATE_ROOT, VERSION } = require('./constants');
99

1010
const access = bindNodeCallback(fs.access);
1111
const mkdir = bindNodeCallback(fs.mkdir);
@@ -18,8 +18,10 @@ function getTemplatePath(login) {
1818
function coauthor({ name, email }) {
1919
return dedent`
2020
# Commiting with commit-with 🤗
21-
21+
2222
Co-Authored-By: ${name} <${email}>
23+
24+
# ${Date.now()}-${VERSION}
2325
`;
2426
}
2527

0 commit comments

Comments
 (0)