-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollect.js
38 lines (35 loc) · 1.17 KB
/
collect.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
32
33
34
35
36
37
38
const readline = require('readline');
const fs = require('fs');
const colors = require('colors');
const opts = {
input: process.stdin,
output: process.stdout,
prompt: 'Exeter Email > '.magenta.bold,
};
const fname = (process.argv.length > 2) ? process.argv[2] : 'ecc-list.txt';
let rl = readline.createInterface(opts);
let motd = [];
motd.push('###########################################');
motd.push('# #');
motd.push('# Welcome to Exeter Computing Club 2017 #');
motd.push('# Check out our GitHub: #');
motd.push('# https://github.com/exeter #');
motd.push('# #');
motd.push('###########################################');
motd.push('');
console.log(motd.join('\n').white.bold);
rl.prompt();
rl.on('line', (input) => {
let eml = input.trim().toLowerCase();
if (eml.indexOf('@') == -1) eml += '@exeter.edu';
fs.appendFileSync(fname, eml+'\n');
console.log('Thanks! We\'ll send you an email announcing our first meeting.');
rl.prompt();
});
rl.on('close', function () {
console.log('Bye!');
});
rl.on('SIGINT', function () {
rl.clearLine();
rl.prompt();
});