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

warun

v1.0.0

Published

CLI tool which does Watch and Run.

Downloads

462

Readme

warun

npm version Downloads/month Build Status Build Status codecov Dependency Status

Watch files and run a command when they change.

⤴️ Motivation

This is CLI tool similar to chokidar-cli. However, this does not run the command immediately if changes happen while the command is running. In that case, this waits for the finish of the previous command then this runs the command. This will be useful if the command needs a long time.

💿 Installation

Use npm to install.

$ npm install -D warun

Requirements

  • Node.js 4 or later.

📖 Usage

CLI command

Usage: warun <FILES> [OPTIONS] -- <COMMAND> [COMMAND_ARGS]

    Watch files and Run a command.

    FILES .......... One or more glob patterns to watch files.
    OPTIONS ........ Options below.
    COMMAND ........ The command name to run.
    COMMAND_ARGS ... The arguments of the command.

Options:
    --no-initial .......... The flag to prevent the first run at ready.
    --debounce <number> ... The debounce wait time in milliseconds.

Examples:
    $ warun lib test -- npm test
    $ warun src --no-initial -- npm run build

Node.js API

const warun = require("warun")

// Start watching
const watcher = warun.watch(["src"], "npm", ["run", "build"])

// Stop watching
watcher.close()

watcher = new warun.Watcher(patterns, command, args, options)

The watcher class. This class inherits EventEmitter.

Parameters
  • patterns (string | string[]) ... The glob patterns of target files.
  • command (string) ... The command to run.
  • args (string[]) ... The arguments of the command.
  • options (object) ... The options.
    • options.initial (boolean) ... The flag to run the command at ready. Default is true.
    • options.debounce (number) ... The debounce wait time in milliseconds. Default is 250.

watcher.requestCommand()

Request to run the command. Calls of this method are debounced.

watcher.open()

Start to watch files.

watcher.close()

Stop watching.

watcher.on("ready", () => {})

The ready event. It emits this event once after the watching of all target files started.

watcher.on("change", (event) => {})

The change event of files. It emits this event on every change of files.

  • event.type is the type of the change.
  • event.path is the path to the changed file.

watcher.on("error", (error) => {})

The error event of files. It emits this event on every error of the watcher.

📰 Changelog

🍻 Contributing

Contributing is welcome ❤

Please use GitHub's Issues/PRs.

Development Tools

  • npm test runs tests and measures coverage.
  • npm run coverage shows the coverage result of npm test command.
  • npm run lint runs ESLint.
  • npm run watch runs warun to run tests on every file change.