Chapter 2: file watching change

This commit is contained in:
Beth Griggs
2020-05-19 13:30:10 +01:00
parent 6213545e5e
commit ce759b45a7
3 changed files with 6 additions and 12 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
HELLO!
dfadfHELLO!
ls
Hello again;
gs
@@ -9,4 +9,4 @@ HELLO!
sdda
dfsdf
dsad
sdasd
sdasd
+4 -2
View File
@@ -1,6 +1,8 @@
const fs = require("fs");
const file = "./file.txt";
const moment = require("moment");
fs.watchFile(file, (current, previous) => {
return console.log(`${file} updated ${time}`);
fs.watch(file, (eventType, filename) => {
const time = moment().format("MMMM Do YYYY, h:mm:ss a");
return console.log(`${filename} updated ${time}`);
});
-8
View File
@@ -1,8 +0,0 @@
const fs = require("fs");
const file = "./file.txt";
const moment = require("moment");
fs.watch(file, (eventType, filename) => {
const time = moment().format("MMMM Do YYYY, h:mm:ss a");
return console.log(`${filename} updated ${time}`);
});