chapter 2: initial samples
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
HELLO!
|
||||
ls
|
||||
Hello again;
|
||||
gs
|
||||
gsgds
|
||||
gsdsdf
|
||||
sddsf
|
||||
sdfsd
|
||||
sdda
|
||||
dfsdf
|
||||
dsad
|
||||
sdasd
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "file-watching",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"moment": {
|
||||
"version": "2.24.0",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
|
||||
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "file-watching",
|
||||
"version": "1.0.0",
|
||||
"main": "watch.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"moment": "^2.24.0"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"description": ""
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
const fs = require('fs');
|
||||
const file = './file.txt';
|
||||
|
||||
fs.watchFile(file, (current, previous) => {
|
||||
return console.log(`${file} updated ${time}`)
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
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