
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@pulsar-edit/pathwatcher
Advanced tools
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.watchPathand is usually a better choice.If you’re here because you want a general-purpose file-watching library for Node, use
nsfwinstead.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').
npm install pathwatcher
git submodule init && git submodule updatenpm install to install the dependenciesnpm test to run the specsThis 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.
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.
event can be any of rename, delete, or change, where change means that the file’s contents changed somehow.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).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 DirectoryThese 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:
FAQs
Watch files and directories for changes
We found that @pulsar-edit/pathwatcher demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.