npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pulsar-edit/pathwatcher

v9.0.2

Published

Watch files and directories for changes

Downloads

237

Readme

node-pathwatcher

Watch files and directories for changes.

[!IMPORTANT] This library is used in Pulsar in several places for compatibility reasons. The nsfw library is more robust and more widely used; it is available in Pulsar via atom.watchPath and is usually a better choice.

If you’re here because you want a general-purpose file-watching library for Node, use nsfw instead.

The purpose of this library’s continued inclusion in Pulsar is to provide the File and Directory classes that have long been available as exports via require('atom').

Installing

npm install pathwatcher

Building

  • Clone the repository
  • git submodule init && git submodule update
  • Run npm install to install the dependencies
  • Run npm test to run the specs

Caveats

This module is context-aware and context-safe; it can be used from multiple worker threads in the same process. If you keep a file-watcher active, though, it’ll keep the environment from closing; you must stop all watchers if you want your script or thread to finish.

If you’re using it in an Electron renderer process, you must take extra care in page reloading scenarios. Be sure to use closeAllWatchers well before the page environment is terminated — e.g., by attaching a beforeunload listener.

Using

const PathWatcher = require('pathwatcher');

watch(filename, listener)

Watch for changes on filename, where filename is either a file or a directory. filename must be an absolute path and must exist at the time watch is called.

The listener callback gets two arguments: (event, path). event can be rename, delete or change, and path is the path of the file which triggered the event.

The watcher is not recursive; changes to the contents of subdirectories will not be detected.

Returns an instance of PathWatcher. This instance is useful primarily for the close method that stops the watch operation.

Caveats

  • Watching a specific file or directory will not notify you when that file or directory is created, since the file must already exist before you start watching the path.
  • When watching a file, event can be any of rename, delete, or change, where change means that the file’s contents changed somehow.
  • When watching a directory, event can only be change, and in this context change signifies that one or more of the directory’s children changed (by being renamed, deleted, added, or modified).
  • A watched directory will not report when it is renamed or deleted. If you want to detect when a given directory is deleted, watch its parent directory and test for the child directory’s existence when you receive a change event.

PathWatcher::close()

Stop watching for changes on the given PathWatcher.

closeAllWatchers()

Stop watching on all subscribed paths. All existing PathWatcher instances will stop receiving events. Call this if you’re going to end the process; it ensures that your script will exit cleanly.

getWatchedPaths()

Returns an array of strings representing the actual paths that are being watched on disk.

pathwatcher watches directories in all instances, since it’s easy to do so in a cross-platform manner.

File and Directory

These are convenience wrappers around some filesystem operations. They also wrap PathWatcher.watch via their onDidChange (and similar) methods.

Documentation can be found on the Pulsar documentation site: