Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-watcher

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-watcher - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

readme.md

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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc