Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cli-error-notifier

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-error-notifier

Send native desktop notifications when CLI apps fail

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
757
increased by70.88%
Maintainers
2
Weekly downloads
 
Created
Source

npm version Build Status Coverage devDependency Status Dependency Status

cli-error-notifier

Send native desktop notifications when CLI apps fail

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

Usage

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 build src",
  }
}

With using cli-error-notifier you can simply get a desktop notification just when the linting fails:

{
  "scripts": {
    "eslint": "onerror \"eslint build 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 build 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.

Install

To use it in your project:

$ npm i -D cli-error-notifier

To use it globally;

$ npm i -g cli-error-notifier

It requires Node.js (v4 or greater).

Options

$ onerror --help

  Send native desktop notifications when 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   Define 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   Shows the version number.
	  --help     -h   Shows 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

Cross platform compatibility

This is using 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.

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

License

MIT © Michael Kühnel

Keywords

FAQs

Package last updated on 29 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc