-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcAutosave.js
32 lines (27 loc) · 853 Bytes
/
mcAutosave.js
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
const events = require('events');
const fs = require('fs');
const readline = require('readline');
(async function processLineByLine() {
try {
const rl = readline.createInterface({
input: fs.createReadStream('/Users/nephaelia/Documents/GitHub/MCCC-Log-Backup-Project/example mccc logs/mc_cmd_center.log'),
crlfDelay: Infinity
});
rl.on('line', (line) => {
console.log(line);
var arr = line;
function join(arr) {
return [...new Set(arr)];
}
fs.appendFile('/Users/nephaelia/Documents/GitHub/MCCC-Log-Backup-Project/example mccc logs/mcbackuptest.txt', "\n" + arr, err => {
if (err) {
console.error(err);
}
});
});
await events.once(rl, 'close');
console.log('Reading file line by line with readline done.');
} catch (err) {
console.error(err);
}
})();