simple-watcher
Advanced tools
Comparing version 4.0.0 to 4.0.1
16
index.js
@@ -11,4 +11,4 @@ 'use strict' | ||
function watchDir (dirToWatch, options, callback) { | ||
const last = {filePath: null, timestamp: 0} | ||
const w = fs.watch(dirToWatch, {persistent: true, recursive: !options.shallow}, (event, fileName) => { | ||
const last = { filePath: null, timestamp: 0 } | ||
const w = fs.watch(dirToWatch, { persistent: true, recursive: !options.shallow }, (event, fileName) => { | ||
// On Windows fileName may actually be empty. | ||
@@ -18,6 +18,2 @@ // In such case assume this is the working dir change. | ||
if (options.shallow) { | ||
return callback(filePath) | ||
} | ||
fs.stat(filePath, (err, stat) => { | ||
@@ -60,3 +56,3 @@ // If error, the file was likely deleted. | ||
options.ledger.add(dir) | ||
watchDir(dir, {shallow: true}, (entityPath) => { | ||
watchDir(dir, { shallow: true }, (entityPath) => { | ||
fs.stat(entityPath, (err, stat) => { | ||
@@ -76,3 +72,3 @@ if (err) { // Entity was deleted. | ||
function watchFile (filePath, options, callback) { | ||
options = options.interval ? {interval: options.interval} : {} | ||
options = options.interval ? { interval: options.interval } : {} | ||
fs.watchFile(filePath, options, (curr, prev) => { | ||
@@ -86,3 +82,3 @@ curr.mtime === 0 && fs.unwatchFile(filePath) // Unwatch if deleted. | ||
const callback = arg2 || arg1 | ||
const options = arg2 ? arg1 : {toleance: TOLERANCE} | ||
const options = arg2 ? arg1 : { toleance: TOLERANCE } | ||
options.tolerance = process.platform === 'win32' ? (options.tolerance || TOLERANCE) : 0 // Disable tolerance if not on Windows. | ||
@@ -106,3 +102,3 @@ options.fallback = options.fallback || !PLATFORMS.includes(process.platform) | ||
const entitiesToWatch = args.filter(a => !a.startsWith('--')) | ||
const options = {shallow: args.includes('--shallow'), fallback: args.includes('--fallback')} | ||
const options = { shallow: args.includes('--shallow'), fallback: args.includes('--fallback') } | ||
@@ -109,0 +105,0 @@ watch(entitiesToWatch, options, fileName => { |
{ | ||
"name": "simple-watcher", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "\"A simple directory watcher.\"", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7064
101