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

hyper-notifier

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyper-notifier - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

62

index.js

@@ -1,15 +0,22 @@

const notifier = require('node-notifier')
let notifications = []
const notifier = require('node-notifier');
const stripAnsi = require('strip-ansi');
let notifications = [];
let notifierString;
exports.middleware = (store) => (next) => (action) => {
exports.middleware = store => next => action => {
if ('SESSION_ADD_DATA' === action.type) {
const { data } = action;
registerConfigs()
const {data} = action;
registerConfigs();
if (isNotifierString(data)) {
// load notification configs
const instanceOverrides = findNotifierString(data)
let instanceOverrides = findNotifierString(data);
if(instanceOverrides) {
notifier.notify(instanceOverrides);
if (instanceOverrides) {
instanceOverrides.message = stripAnsi(data).replace(/\r?\n|\r|%/g, '');
if (instanceOverrides.reply) {
notifier.notify(instanceOverrides, responseHandler(next, action, store));
} else {
notifier.notify(instanceOverrides);
}
}

@@ -23,5 +30,20 @@ }

function sendSessionData(uid, data, escaped) {
return (dispatch, getState) => {
dispatch({
type: 'SESSION_USER_DATA',
data,
effect() {
// TODO
// If no uid is passed, data is sent to the active session.
const targetUid = uid || getState().sessions.activeUid;
window.rpc.emit('data', {uid: targetUid, data, escaped});
}
});
};
}
function isNotifierString(data) {
return new RegExp('(' + notifierString + ')').test(data)
return new RegExp('(' + notifierString + ')').test(data);
}

@@ -31,20 +53,26 @@

return notifications.find(n => {
return new RegExp('(' + n.test + ')').test(data)
})
return new RegExp('(' + n.test + ')').test(data);
});
}
const responseHandler = (next, action, store) => (error, response, metadata) => {
if (metadata && metadata.activationValue) {
sendSessionData(action.uid, `${metadata.activationValue}\r`)(store.dispatch, store.getState);
}
};
function registerConfigs() {
const notifierConfigs = window.config.getConfig().hyperNotifier
const notifierConfigs = window.config.getConfig().hyperNotifier;
if(notifications.length > 0 && !notifierString) {
return
if (notifications.length > 0 && !notifierString) {
return;
}
if(notifierConfigs.notifications) {
notifications = notifierConfigs.notifications
if (notifierConfigs.notifications) {
notifications = notifierConfigs.notifications;
}
if (!notifierString) {
notifierString = notifications.map(n => n.test).join(')|(')
notifierString = notifications.map(n => n.test).join(')|(');
}
}
{
"name": "hyper-notifier",
"version": "1.0.5",
"version": "1.0.6",
"description": "A notifications and alerting plugin for Hyper.js",

@@ -27,4 +27,5 @@ "main": "index.js",

"dependencies": {
"node-notifier": "^6.0.0"
"node-notifier": "^6.0.0",
"strip-ansi": "5.2.0"
}
}
# hyper-notifier
![](https://cl.ly/660846eb0602/Screen%252520Recording%2525202019-09-29%252520at%25252006.07%252520PM.gif)
![](https://cl.ly/3191dc78d5b7/Screen%252520Recording%2525202019-10-02%252520at%25252012.43%252520AM.gif)

@@ -22,6 +22,11 @@ **hyper-notifier is a notifications and alerting plugin for [Hyper.js](https://hyper.is/)**. This allows similar functionality to Iterm which allow users to add a config, and register alerts based on console output. Under the hood it is a wrapper around [Node Notifier](https://github.com/mikaelbr/node-notifier)

test: 'ERR!', // the string we are testing for
title: 'ERR! was detected!', // node-notifier config
message: 'check hyperterm', // node-notifier config
title: 'ERR! was detected!', // notification title
sound: 'Funk',
}
{
test: 'y/n', // the string we are testing for
title: 'response needed', // notification title
reply: true, // wait for response
wait: 30 // wait 30 seconds
}
]

@@ -28,0 +33,0 @@ }

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