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

simplemon

v1.0.4

Published

Simple file monitor that executes commands each time a file changes

Downloads

9

Readme

simplemon

A simple file monitor that executes a given command each time a file change occurs inside the tracked directory.

Installation

npm install -g simplemon

Usage

simplemon COMMAND

Tracks file changes within the directory where it was launched, and launches COMMAND when a file change occurs.

The command supports a wildcard, {} , which is replaced with the modified file name before the command is launched.
(similar to the {} wildcard of find -exec).

File tracking works recursively on subfolders.

Ignore rules can be specified in a .smonignore file. The rules work in the .gitignore fashion.

Examples

1. Prints something whenever a file changes

simplemon echo Something changed

2. Log the full path of each modified file (make sure to add an ignore rule for log.txt)

simplemon echo {} >> log.txt

3. Calls jade to render .jade files into .html, each time a .jade file changes.

simplemon jade -O output {}

In this case the .smonignore file should ignore anything else except .jade:

*
!*.jade

4. Restart node each time a file changes somewhere in the current directory:

simplemon node app.js

(this works in the same way as nodemon)

Configuration

simplemon supports some config options that can be specified in a smonconfig.json file within the directory where it is run.

Here are the options and their default values:

{
	"command" : null,
	"threshold" : 200,
	"restart" : true,
	"restartDelay" : 500,
	"debug" : false
}

command : the COMMAND can be specified in the config file as well (if it's specified both in the shell and in the config file, the shell version is used).

If piping or redirection are needed, setting the command in the config file is the way to go. (in contrast, when using the shell, piping and redirection are applied to the ouput of simplemon, rather than the ouput of the command). Also, in this scenario, "restart" needs to be false (see the restart option below).

Example: Log each line that contains a keyword from a modified file:

smonconfig.json

{
	"command" : "cat {} | grep foobar >> log.txt",
	"restart" : false
}

.smonignore

log.txt

Run it without any parameters:

simplemon

threshold : interval (in milliseconds) inside which changes to the same file are ignored.

For example, a file save triggers a COMMAND to be launched by simplemon. If the same file is saved again withing the 200ms threshold interval, the COMMAND is not launched a second time.

restart : If true, the processes that are already running are restarted.

If a COMMAND is launched with no wildcard {} (for instance node app.js), the process is restarted each time a file changes within its directory.

If a COMMAND is launched with a wilcard {}, the process is restarted only when file received as a parameter changes.

If false, a new process is launched without killing the existing one.

Note: When "restart: true" simplemon needs to kill/restart a single running process, therefore command chaining (piping, etc.) will not work.

restartDelay : Delays the restart of the process with the given value (milliseconds). This should allow some processes to do cleanup after they received the kill message.

debug : more output messages