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

cli-error-notifier

v3.0.2

Published

Sends native desktop notifications if CLI apps fail

Downloads

2,792

Readme

npm version Coverage

cli-error-notifier

Sends native desktop notifications if CLI apps fail

Technically: if a command exits with an exit code other than 0

Install

To use it in your project:

$ npm install --save-dev cli-error-notifier

To use it globally:

$ npm install --global cli-error-notifier

It requires Node.js (v4 or greater).

General usage

$ onerror --help

  Sends native desktop notifications if CLI apps fail

	Usage
	  $ onerror <command> [options]

	Options
	  --title,   -t   Sets the title of the notification.
	                  Default: "An error has occured"
	  --message, -m   Sets the message body of the notification.
	                  Default: "Check the terminal for more information"
	  --icon,    -i   Sets an icon. Can be any absolute path.
	  --sound,   -s   Defines which sound to use.
	                  Use "mute" to disable default sound notification.
	                  Options: Mute, Basso, Blow, Bottle, Frog, Funk, Glass, Hero,
	                           Morse, Ping, Pop, Purr, Sosumi, Submarine, Tink
	                  Default: Bottle
	  --version  -v   Displays the version number.
	  --help     -h   Displays the help.

	Examples
	  $ onerror "wget unknown-host.xyz"
	  $ onerror "wget unknown-host.xyz" -s mute
	  $ onerror "wget unknown-host.xyz" -t Error -m "My error message"
	  $ onerror "wget unknown-host.xyz"  -s Glass -i https://cdn.rawgit.com/npm/logos/31945b5c/npm%20square/n-64.png

Usage with npm scripts

This little CLI comes in handy when writing build scripts.

Let’s imagine you have setup the following npm script for linting your JavaScript files:

{
  "scripts": {
    "eslint": "eslint src",
  }
}

With using cli-error-notifier a desktop notification can be generated at the moment the linting fails:

{
  "scripts": {
    "eslint": "onerror \"eslint src\"",
  }
}

This is especially useful for watching files while developing. You could use it in conjunction with onchange like in the following example:

{
  "scripts": {
    "eslint": "eslint src",
    "eslint:fix": "npm run eslint --silent -- --fix",
    "eslint:watch": "onchange \"src/**/*.js\" -- onerror \"npm run eslint --silent\""
  }
}

It also works flawlessly together with npm-run-all.

Cross platform compatibility

cli-error-notifier uses the brilliant node-notifier and therefore should work with Notification Center for macOS, notify-osd/libnotify-bin for Linux, Toasters for Windows 8/10, or taskbar Balloons for earlier Windows versions. Growl is used if none of these requirements are met.

Related

  • onchange - Watch files and folders and run a command when anything is changed.
  • npm-run-all - CLI tool to run multiple npm-scripts in parallel or serial.

License

MIT © Michael Kühnel