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

jung

v2.1.0

Published

trigger commands on file change events

Downloads

809

Readme

jung

Build Status npm install

lightweight, flexible, file-watching command runner

installation

npm install -g jung

why

so you can do jung -f '\.js$' -- browserify main.js -o bundle.js

or

jung *.md -- cat \$JUNG_FILE | marked -o \$JUNG_BARENAME.html

or

jung -r /var/log -- echo \$JUNG_FILE changed!

or any other variety of neat stuff.

usage

jung [options] [files] -- <command>

Options are

  • --root, -r <dir> Watch files in <dir>, default cwd
  • --dirs, -d <regex> Only watch sub directories matching <regex>
  • --notdirs, -D <regex> Ignore sub directories matching <regex>
  • --files, -f <regex> Only watch files matching <regex>
  • --notfiles, -F <regex> Ignore files matching <regex>
  • --wait, -w <time> Debounce reaction for <time> ms, default 300
  • --timeout, -t <time> Wait <time> ms after SIGTERM to SIGKILL, default 500
  • --kill, -k Rather than queueing command runs, kill child process
  • --quiet, -q Do not show output from <command>
  • --run, -R Run <command> at first start
  • --version, -v Print jung version
  • --help, -h Print help

Commands are anything you can run in your shell. Including a shell script, for more complicated things!

notes

When using jung as part of an npm run script, you will need to escape any \ in order to avoid JSON parsing errors.

example

{
  // ...
  "scripts": {
    "watch-md": "jung -f '\\.md$' -- make html"
  }
  // ...
}

When your command is fired, the following environment variables will be available:

  • $JUNG_FILE - Full path to file that triggered the command
  • $JUNG_DIR - The directory the trigger file lives in
  • $JUNG_FILENAME - Just the filename part of the trigger file
  • $JUNG_EXTENSION - Just the extension of the trigger file
  • $JUNG_BARENAME - Trigger filename with no extension

If you run jung with --run these environment variables will be blank strings when the initial execution occurs.

This works really well with scripts, but for one-liners you will need to escape the $ to prevent your shell from replacing it too early.

bad

jung -- echo $JUNG_FILE did something!

good

jung -- echo WHOA CHECKOUT \$JUNG_FILE || jung -- echo 'wee $JUNG_FILE'

as a module

var jung = require('jung')

var options = { files: ['\.js$', /\.md$/], quiet: true }
  , command = 'sh recompile_file.sh $JUNG_FILE'

jung(options, command).start()

module notes

Options accepts an object of options with keys matching the long form of any acceptable command line flag, for example files, notfiles, wait, etc.

files, notfiles, dirs, and notdirs each accept an array of either strings or RegExps or any combination thereof.

Any command line flags that do not accept an argument require a boolean value in the options object and they all default to false.

The second argument is the command which can be either a string of the command to be run or an array of each part of the command (i.e. command.split(' '))

license

MIT