-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
33 lines (30 loc) · 909 Bytes
/
test.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
const { readFile, readFileSync, writeFile } = require('fs');
console.log("start");
readFile('./content/first.tt', 'utf-8',((err, result) => {
if(err){
console.log(err);
return;
}
const first = result;
console.log("handling first file")
// read second file
readFile('./content/subdir/second.txt', {encoding:'utf-8'},
((err, result) =>{
if(err){
console.log(err);
return;
}
const second = result;
console.log("handling second file");
// write the file
writeFile('./content/subdir/read_write_sync.txt',
`What I wrote : ${first}, ${second}`,((err, result) => {
if(err){
console.log(err);
return;
}
console.log(`The result: ${first} and ${second}`);
}));
}));
}));
console.log("Ready for the next task");