hyper-notifier
Advanced tools
Comparing version 1.0.2 to 1.0.4
37
index.js
const notifier = require('node-notifier'); | ||
let notifications = [] | ||
let newConfig = {} | ||
let defaultConfig = { | ||
registered: false, | ||
sound: 'Basso' | ||
} | ||
let notifierString; | ||
exports.onApp = registerConfigs | ||
exports.middleware = (store) => (next) => (action) => { | ||
@@ -14,13 +12,8 @@ if ('SESSION_PTY_DATA' === action.type) { | ||
if (isNotifierString(data)) { | ||
// load user configs | ||
if(!defaultConfig.registered) { | ||
defaultConfig = registerConfigs() | ||
// load notificaion configs | ||
const instanceOverrides = findNotifierString(data) | ||
if(instanceOverrides) { | ||
notifier.notify(instanceOverrides); | ||
} | ||
const instanceOverrides = findNotifierString(data) || {} | ||
notifier.notify({ | ||
...defaultConfig, | ||
...instanceOverrides | ||
}); | ||
} | ||
@@ -35,3 +28,3 @@ next(action); | ||
function isNotifierString(data) { | ||
return new RegExp('(' + notifications.map(n => n.test).join(')|(') + ')').test(data) | ||
return new RegExp('(' + notifierString + ')').test(data) | ||
} | ||
@@ -47,7 +40,5 @@ | ||
const notifierConfigs = config.getConfig().hyperNotifier | ||
if(notifierConfigs.settings) { | ||
newConfig = { | ||
...notifierConfigs, | ||
registered: true | ||
} | ||
if(notifications.length > 0 && !notifierString) { | ||
return | ||
} | ||
@@ -59,3 +50,5 @@ | ||
return {...defaultConfig, ...newConfig} | ||
if (!notifierString) { | ||
notifierString = notifications.map(n => n.test).join(')|(') | ||
} | ||
} |
{ | ||
"name": "hyper-notifier", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"description": "A notifications and alerting plugin for Hyper.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,3 +13,3 @@ # hyper-notifier | ||
``` | ||
Then register your base settings (optional) and notifications (required) in your `.hyper.js` | ||
Then register your notifications in your `.hyper.js` | ||
@@ -20,5 +20,2 @@ ``` | ||
hyperNotifier: { | ||
settings: { | ||
sound: 'Funk' | ||
}, | ||
notifications: [ | ||
@@ -28,3 +25,4 @@ { | ||
title: 'ERR! was detected!', // node-notifier config | ||
message: 'check hyperterm' // node-notifier config | ||
message: 'check hyperterm', // node-notifier config | ||
sound: 'Funk', | ||
} | ||
@@ -31,0 +29,0 @@ ] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4428
39
45