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 🙏

© 2024 – Pkg Stats / Ryan Hefner

sentry2

v0.2.0

Published

Watch files (using a path, wildcards, or a regex) and execute a function or shell command.

Downloads

23

Readme

Sentry

Sentry is a simple node tool to watch for file changes (using a path, wildcards, or regexes) and execute a function or shell command. It's like a watchr or guard for node.

Installation

$ npm install sentry2

Example

var sentry = require('sentry2');

// Watch changes in file.js
sentry.watch('file.js', function (error, filename) {
  console.log("A change has been made in " + filename);
});

// Watch changes on any file ending in .coffee one directory deep
sentry.watch('fld/*.coffee', callback);

// Watch changes recursively on any files 
sentry.watch('fld/**/*', callback);

// Watch files recursively that match a regex
sentry.watchRegExp('fld/', /regex/, callback);

// If you pass a string instead of a function it'll execute that child process
sentry.watch('file.coffee', 'coffee -c');

API

Sentry comes with two methods watch and watchRegExp.

sentry.watch(filePath, [task], callback)

When running a child process you may optionally pass a callback with the arguments (error, filename, stdout, stderr)

sentry.watch('file.js', 'coffee -c', function (error, filename, stdout, stderr) {/*...*/});

Or just pass a callback and Sentry will pass the filename to the callback

sentry.watch('file.js', function (error, filename) {/*...*/});

Feel free to use wildcards with extensions


// Find all files one directory deep
sentry.watch('/folder/*', callback);

// Find all files one directory deep ending in .coffee
sentry.watch('/folder/*.coffee', callback);

// Find all files recursively
sentry.watch('/folder/**/*', callback);

// Find all files recursively ending in .txt
sentry.watch('/folder/**/*.txt', callback);

sentry.watchRegExp(root, regex, [task], callback)

Just like sentry.watch but instead you must pass a root directory and regular expression to match files against.


// Find all files in this folder that end in .coffee
sentry.watchRegExp('', /\.coffee$/, callback);

// Find all files in the adjacent 'test' folder that begin with `test_` and end in `.coffee`
sentry.watchRegExp('../tests/', /^test_,.coffee$/, callback);

To run tests

npm test