Socket
Socket
Sign inDemoInstall

@webgap/notifier

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webgap/notifier - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

44

index.js
/**
* (C) Copyright 2014 WebGAP (http://www.webgap.eu/).
* (C) Copyright 2015 WebGAP (http://www.webgap.eu/).
*

@@ -25,3 +25,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var async = require('async');
var instances = {};
var util = require('util');
var systems = {};

@@ -45,6 +45,8 @@ var defaultSystem;

return callback(error);
} else {
}
else {
options.notificationSystems = [defaultSystem];
}
} else {
}
else {
if (!Array.isArray(options.notificationSystems)) {

@@ -58,3 +60,3 @@ options.notificationSystems = [options.notificationSystems];

async.each(options.notificationSystems, function sendNotification(system, done) {
var instance = instances[system];
var instance = systems[system] ? systems[system].instance : null;
if (instance) {

@@ -65,6 +67,9 @@ try {

});
} catch (err) {
}
catch (err) {
return done(err);
}
} else {
}
else {
console.warn('Trying to notify using a non registered system: %s', system);
return done();

@@ -86,15 +91,22 @@ }

system = system || {};
// check if class is an instance of AbstractNotificationSystem
if (typeof system.instance.notify !== 'function') {
var error = new Error('The class provided must implement a \'notify\' function. Cannot register Notification System: %s', system.name);
// check if class implements a notify method
if (system.instance && typeof system.instance.notify !== 'function') {
var error = new Error(util.format('The class provided must implement a \'notify\' function. Cannot register Notification System: %s', system.name));
console.error(error.message);
throw error;
}
console.info('Notification System registered: %s', system.name);
instances[system.name] = system.instance;
systems[system.name] = system.name;
if (system.defaultSystem) {
if (systems[system.name]) {
console.warn('Notification system with name %s is already registered. Please unregister if is the case, or change the its name and try again.', system.name);
return;
}
systems[system.name] = {};
systems[system.name].instance = system.instance;
systems[system.name].name = system.name;
systems[system.name].default = Boolean(system.defaultSystem) ? system.defaultSystem : false;
console.info('Notification system registered: %s', system.name);
if (systems[system.name].default) {
defaultSystem = system.name;
console.info('Default notification system set to: %s', defaultSystem);
}
return;
};

@@ -108,3 +120,5 @@

module.exports.unregister = function register(systemName) {
delete instances[systemName];
delete systems[systemName];
console.info('Notification system unregistered: %s', systemName);
return;
};

@@ -5,5 +5,5 @@ {

"author": "Manuel Martins <manuelmachadomartins@gmail.com>",
"version": "0.1.2",
"version": "0.1.3",
"license": "Apache-2.0",
"engine": "node >= 0.12.0",
"engine": "node >= 5.0.0",
"main": "./index",

@@ -32,6 +32,6 @@ "scripts": {

"devDependencies": {
"codeclimate-test-reporter": ">=0.1.x",
"istanbul":">=0.3.x",
"mocha": ">=2.2.x"
"codeclimate-test-reporter": "0.1.x",
"istanbul":"0.3.x",
"mocha": "2.2.x"
}
}
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