Chapter 2: file watching change
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
HELLO!
|
dfadfHELLO!
|
||||||
ls
|
ls
|
||||||
Hello again;
|
Hello again;
|
||||||
gs
|
gs
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const file = "./file.txt";
|
const file = "./file.txt";
|
||||||
|
const moment = require("moment");
|
||||||
|
|
||||||
fs.watchFile(file, (current, previous) => {
|
fs.watch(file, (eventType, filename) => {
|
||||||
return console.log(`${file} updated ${time}`);
|
const time = moment().format("MMMM Do YYYY, h:mm:ss a");
|
||||||
|
return console.log(`${filename} updated ${time}`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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}`);
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user