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

miteru

v0.7.0

Published

simple file watcher

Downloads

41

Readme

npm npm

miteru

Basic file watcher.

Easy to use

CLI

miteru '**/*.js' -e 'echo $evt: $file'

Module

var miteru = require( './dist/miteru.js' )
var watcher = miteru.watch( function ( evt, filepath ) {
  switch ( evt ) {
    case 'init':
      // only emitted once during the first polling cycle ( if the file exists )
      console.log( 'init: ' + filepath )
      break

    case 'add':
      // file was added ( did not exists previously, exists now )
      console.log( 'add: ' + filepath )
      break

    case 'change':
      // file was changed ( existed previously, exists now, mtime or content changed )
      console.log( 'change: ' + filepath )
      break

    case 'unlink':
      // file was removed ( existed previously, does not exist now )
      console.log( 'unlink: ' + filepath )
      break
  }
} )

watcher.add( 'src/**/*.js' )

setTimeout( function () {
  console.log( watcher.getWatched() ) // array of files being watched
  watcher.clear()
  console.log( watcher.getWatched() ) // empty array ( no files being watched )

  setTimeout( function () {
    watcher.add( 'package.json' )

    setTimeout( function () {
      watcher.clear() // will exit naturally because no files are being watched
    }, 3000 )
  }, 3000 )
}, 5000 )

Example

$ miteru '**/*.js' -e 'echo file: $file'
events watched: add,change
watching pattern: **/*.js
10 files are being watched

CLI STDIN commands

The miteru process listens for line separated STDIN commands ( first match algorithm )

list, files, watched

prints out the files being watched

$ miteru '**/*.js' -e 'echo file: $file'
events watched: add,change
watching pattern: **/*.js
11 files are being watched
fil
  /Users/mollie/code/miteru/cli.js
  /Users/mollie/code/miteru/dist/miteru.js
  /Users/mollie/code/miteru/sample.js
  /Users/mollie/code/miteru/src/index.js
  /Users/mollie/code/miteru/test/bench-readdir.js
  /Users/mollie/code/miteru/test/samples/animal.js
  /Users/mollie/code/miteru/test/samples/main.js
  /Users/mollie/code/miteru/test/test-close.js
  /Users/mollie/code/miteru/test/test-unwatch.js
  /Users/mollie/code/miteru/test/test.js
  /Users/mollie/code/miteru/test/tmp/unwatch.js
watched files: 11

execute

prints out the execute command being used

$ ./cli.js '**/*.js' -e 'echo file: $file'
events watched: add,change
watching pattern: **/*.js
11 files are being watched
ex
  -e echo file: $file

Install

locally ( project specific, for use with npm scripts )

npm install miteru

globally

npm install -g miteru

Why

Simple file watching that just works ™ as fast and as painless as possible. Intended for watching files during development qickly and easily to trigger rebuilds etc.

Alternatives

chokidar

chokidar-cli

How

Elastic fs.stat polling. Rank orders each file by how often it's changed and sets polling priority accordingly.

Usage

$ miteru --help

Usage: miteru [options] <files>

Options:

-e, --execute <command>         Execute a command when a file event occurs.

-i, --init                      Listen for file init events.
-a, --add                       Listen for file add events.
-c, --change                    Listen for file change events.
-u, --unlink                    Listen for file unlink events.

                                By default --add and --change events
                                are listened to if no events are specified.

--limit <milliseconds>          Minimum allowed polling interval.

-v, --verbose                   Verbose output.
--stats                         Print detailed stats every 1 second.

-V, --version                   Print miteru version and exit.
-h, --help                      Print help ( this text ) and exit.

Examples:
  miteru -e 'npm run build' "src/**/*.js"
  miteru -iacu -e 'echo $evt: $file' "src/**/*.js"
  miteru -e 'sshpass -p "giraffe" scp $file [email protected]:/home/user/app/$file'

    NOTE: using sshpass -p "password" will add your password to bash history -- use -f to load password from file.

Test

npm test