git ssb

1+

kas / microscope-alpha



Commit 08d7e1969f64aff2a9ab15b3aa31a537402a5792

add script to log history

ansuz committed on 2/10/2018, 10:57:51 AM
Parent: b68be56782b274c1488481234e554d147aa5438e

Files changed

log.jsadded
log.jsView
@@ -1,0 +1,35 @@
1 +var message = process.argv.slice(2).join(' ').trim();
2 +if (!message) {
3 + console.error("you must specify a message to add");
4 + console.error('$ node log.js "@alice added \'dogs\' to the palette"');
5 + process.exit(1);
6 +}
7 +
8 +var pad = function (n){
9 + return n < 10 ? '0'+n : n;
10 +};
11 +
12 +var rfc3339 = function () {
13 + var d = new Date();
14 +
15 + return d.getUTCFullYear() + '-'
16 + + pad(d.getUTCMonth()+1) + '-'
17 + + pad(d.getUTCDate()) + ' '
18 + + pad(d.getUTCHours()) + ':'
19 + + pad(d.getUTCMinutes()) + ':'
20 + + pad(d.getUTCSeconds()) + 'Z';
21 +};
22 +
23 +var format = function (message) {
24 + return rfc3339() + '\t' + message + '\n';
25 +};
26 +
27 +var fs = require("fs");
28 +fs.appendFile('./history.txt', format(message), function (e) {
29 + if (e) {
30 + console.error('could not write to history.txt');
31 + console.error(e);
32 + process.exit(1);
33 + }
34 +});
35 +

Built with git-ssb-web