Git Product home page Git Product logo

alert's Introduction

alert

NOTICE: the alert package name on npm has been given away. This has been deprecated for a long time. See below. Don't use alert from npm if you're expecting an isomorphic alert package.

NOTICE: deprecated use node-notifier instead, it's better maintained, has more options, and is all-around a better package. alert will not get any new updates.


Cross-platform, isomorphic alert, for Node and browser (previously alert-node)

IMPORTANT this project was previously called alert-node. The package name changed in v4. Huge thanks to @iclanzan for the package name!

  • Uses window.alert in the browser.
  • Uses kdialog zenity, yad, notify-send, xmessage, dialog, or whiptail on Linux and BSD (depending on what's available).
  • Uses osascript/System Events on Mac.
  • Uses cscript on Windows (or msg if cscript fails).
  • Defaults to console.log.

Installation:

npm i alert

Usage:

import alert from 'alert'

alert('howdy')

If using the API, you can specify a program to use. This can be one of:

  • dialog (Linux)
  • kdialog (Linux)
  • notify-send (Linux)
  • whiptail (Linux)
  • xmessage (Linux)
  • yad (Linux)
  • zenity (Linux)
  • osascript (Mac)
  • cscript (Windows)
  • msg (Windows)
  • console (console.log)

Note that this will override any internal checks to get the correct program, and will blow up if you get it wrong. It's advised to just use the default behavior.

import alert from 'alert'
alert('hey!', 'yad')

alert also has a cli. npm i -g alert and run alert 'sup brah'.

To disable alert for testing purposes or otherwise, you can set an environment variable DISABLE_ALERT=1.

LICENSE

alert's People

Contributors

dependabot[bot] avatar picakciali avatar yakkomajuri avatar zacanger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

alert's Issues

Add more modern options

  • Mac notification center
  • Windows toasters
  • Windows taskbar
  • notify-osd
  • Growl

These are all handled in this library, which does not handle any of the options alert-node handles. They should be considered higher priority/preference than the current options.

Feature Request: Add option to suppress alert in testing

First of all, thanks for the work! The package helps me a lot!

I'm building a website with Node.js and have recently come across the "issue" that when I run mocha tests, alerts fire on top of the code editor which is rather annoying. I'm using alerts to express errors in the user registration process, which I test quite thoroughly, and, as a result, get a bunch of alerts from it that I have to manually close.

I've fixed the issue for myself with my own little wrapper:

const alert = require('alert');

var generateAlert = module.exports = function(msg) {
    if (process.env.NODE_ENV == "development") {
        alert(msg);
    }
}

When testing, I set NODE_ENV to test which suppresses the alert.

So I was thinking of building a feature where a user can pass options to alert() to determine in which environments alert should or should not fire. thingToUse could also be an option, and not setting the options parameter would of course not change anything.

Something like:

alert("Username already in use", { thingToUse: "yad", env: ["development", "production"]})

It would then read from process.env.NODE_ENV to find the value set by the user.

Wondering if this is of interest or if it just adds unnecessary size to the package. If it is, I'll get on it right away!

Cheers!

Could not see proper notification using 'notify-send' in KDE plasma

Possible bug.
Tried executing following code snippet:

var alert = require('alert-node');
alert('Hello world', 'notify-send');

Expected behavior:
It should have displayed the KDE styled notification

Observed behavior:
Default notification box appeared with provided text.

Environment info (relevant info only):

  System:
    OS: Linux 5.4 Manjaro Linux
    Shell: 5.0.11 - /bin/bash
  Binaries:
    Node: 13.3.0 - /usr/bin/node
    npm: 6.13.4 - /usr/bin/npm

Add Title Support?

At the moment, the alert window (at least on macOS) shows only the message.
Is it (or would it be) possible to give an option to also add a title to be logged or shown in the alert?

Thank you ๐ŸŒธ.

Consider name change

The alert package is owned by @iclanzan. I tweeted them to see if they would hand that over, since there's no code there. If not, switching to isomorphic-alert or similar might be nice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.