-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcmd.js
More file actions
executable file
·52 lines (44 loc) · 1015 Bytes
/
cmd.js
File metadata and controls
executable file
·52 lines (44 loc) · 1015 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
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
#!/usr/bin/env node
/*
* Copyright (c) Maximilian Antoni <max@javascript.studio>
*
* @license MIT
*/
'use strict';
const editor = require('editor');
const changes = require('..');
const argv = require('minimist')(process.argv.slice(2), {
alias: {
file: 'f',
help: 'h'
}
});
/* eslint-disable max-len */
const HELP_TEXT = `usage: changes [--file] [--help]
Options are ...
-f, --file [FILENAME] Specify the name of the changelog file. Defaults to CHANGES.md.
-h, --help Display this help message.
`;
/* eslint-enable */
if (argv.h || argv.help) {
console.log(HELP_TEXT);
process.exit();
}
let file = argv.file;
if (file) {
changes.setFile(file);
} else {
file = changes.getFile();
}
// Write the commit history to the changes file
const previous = changes.write();
// Let the user edit the changes
editor(file, (code) => {
if (code === 0) {
// Add the changes file to git
changes.add(previous);
} else {
// Roll back
changes.abort(previous);
}
});