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

@trex-arms/watchlist

v0.3.2

Published

Recursively watch a list of directories & run a command on any file system changes

Downloads

4

Readme

Features

  • Extremely lightweight
  • Simple fs.watch wrapper
  • Runs on macOS, Linux, and Windows
  • Recursively monitors all subdirectories
  • Optional ignore patterns

While fs.watch has its inconsistencies, efforts are made to normalize behavior across platforms.

Install

$ npm install --save-dev watchlist

Usage

CLI

# Run `npm test` on changes within "src" and "test" contents change
$ watchlist src test -- npm test

# Run `npm test` on changes within "packages", ignoring /fixtures/i
$ watchlist packages --ignore fixtures -- npm test

# Run `lint` script on ANY change
$ watchlist -- npm run lint

API

import { watch } from 'watchlist';

async function task() {
  console.log('~> something updated!');
  await execute_example(); // linter, tests, build, etc
}

// Run `task()` when "{src,test}/**/*" changes
// Must also ignore changes to any `/fixture/i` match
await watch(['src', 'test'], task, {
  ignore: 'fixtures'
});

CLI

The watchlist binary expects the following usage:

$ watchlist [...directory] [options] -- <command>

Important: The -- is required! It separates your command from your watchlist arguments.

Please run watchlist --help for additional information.

API

watch(dirs: string[], handler: Function, options?: Options)

Returns: Promise<void>

Watch a list of directories recursively, calling handler whenever their contents are modified.

dirs

Type: Array<String>

The list of directories to watch.

May be relative or absolute paths. All paths are resolved from the opts.cwd location.

handler

Type: Function

The callback function to run.

Note: This may be a Promise/async function. Return values are ignored.

options.cwd

Type: String Default: .

The current working directory. All paths are resolved from this location. Defaults to process.cwd().

options.ignore

Type: String or RegExp or Array<String | RegExp>

A list of patterns that should not be watched nor should trigger a handler execution. Ignore patterns are applied to file and directory paths alike.

Note: Any String values will be converted into a RegExp automatically.

options.clear

Type: Boolean Default: false

Whether or not the console should be cleared before re-running your handler function.

Note: Defaults to true for the CLI! Pass --no-clear to disable.

options.eager

Type: Boolean Default: false

When enabled, runs the command one time, after watchlist has initialized. When disabled, a change within the dirs list must be observed before the first command execution.

run(command: string, ...args)

Returns: Promise<void>

All arguments to watchlist.run are passed to child_process.exec directly.

Note: Any stdout or stderr content will be piped/forwarded to your console.

command

Type: String

The command string to execute. View child_process.exec for more information.

args

Type: String

Additional child_process.exec arguments.

Important: The callback argument is not available!

License

MIT © Luke Edwards