-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
23 lines (20 loc) · 932 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//requires node js module readline for user input
const readline = require('readline');
//import the getfile function for the start of the process
const getFile = require('./modules/readfile.js');
//create instance of readline interface (configuration for readline)
const rl = readline.createInterface({
//object with input and output streams, terminal to avoid dups on terminals as user writes
input : process.stdin,
output : process.stdout,
terminal : false
})
//readline method prints an output waits for user input
rl.question('Please insert a file path example:(D:\\user\\docs\\file.txt) if nothing is input it will use default file\n',(answer)=>{
//if user doesn't makes an input it will use the default file
if(answer.length>0 ){
getFile(answer);
} else getFile('./employees.txt');
//close the interface and give ups on input/output streams
rl.close();
});