Code files

This commit is contained in:
Akhil
2017-07-31 11:33:31 +05:30
parent 073a63ebdd
commit b9ae409ec0
801 changed files with 17535 additions and 0 deletions
@@ -0,0 +1,16 @@
{
"name": "watching-with-chokidar",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "David Mark Clements",
"license": "MIT",
"dependencies": {
"chokidar": "^1.6.0",
"human-time": "0.0.1"
}
}
@@ -0,0 +1,28 @@
'use strict'
const chokidar = require('chokidar')
const human = require('human-time')
const watcher = chokidar.watch(process.argv[2] || '.', {
alwaysStat: true
})
watcher.on('ready', () => {
watcher
.on('add', (file, stat) => {
console.log(`${file} created ${human((stat.birthtime))}`)
})
.on('unlink', (file) => {
console.log(`${file} removed`)
})
.on('change', (file, stat) => {
const msg = (+stat.ctime === +stat.mtime) ? 'updated' : 'modified'
console.log(`${file} ${msg} ${human((stat.ctime))}`)
})
.on('addDir', (dir, stat) => {
console.log(`${dir} folder created ${human((stat.birthtime))}`)
})
.on('unlinkDir', (dir) => {
console.log(`${dir} folder removed`)
})
})