Skip to content

Commit

Permalink
chore: updates dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelbr committed May 14, 2021
1 parent b9427d4 commit 1265ee3
Show file tree
Hide file tree
Showing 22 changed files with 10,369 additions and 2,343 deletions.
6 changes: 3 additions & 3 deletions example/advanced.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var notifier = require('../');
var nc = new notifier.NotificationCenter();
var path = require('path');
const notifier = require('../');
const nc = new notifier.NotificationCenter();
const path = require('path');

nc.notify(
{
Expand Down
6 changes: 3 additions & 3 deletions example/macInput.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var notifier = require('../');
var nc = new notifier.NotificationCenter();
const notifier = require('../');
const nc = new notifier.NotificationCenter();

var trueAnswer = 'Most def.';
const trueAnswer = 'Most def.';

nc.notify(
{
Expand Down
2 changes: 1 addition & 1 deletion example/message.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var notifier = require('../index');
const notifier = require('../index');

notifier
.notify({ message: 'Hello', wait: true }, function(err, data) {
Expand Down
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var os = require('os');
var utils = require('./lib/utils');
const os = require('os');
const utils = require('./lib/utils');

// All notifiers
var NotifySend = require('./notifiers/notifysend');
var NotificationCenter = require('./notifiers/notificationcenter');
var WindowsToaster = require('./notifiers/toaster');
var Growl = require('./notifiers/growl');
var WindowsBalloon = require('./notifiers/balloon');
const NotifySend = require('./notifiers/notifysend');
const NotificationCenter = require('./notifiers/notificationcenter');
const WindowsToaster = require('./notifiers/toaster');
const Growl = require('./notifiers/growl');
const WindowsBalloon = require('./notifiers/balloon');

var options = { withFallback: true };
const options = { withFallback: true };

var osType = utils.isWSL() ? 'WSL' : os.type();
const osType = utils.isWSL() ? 'WSL' : os.type();

switch (osType) {
case 'Linux':
Expand Down
10 changes: 5 additions & 5 deletions lib/checkGrowl.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var net = require('net');
const net = require('net');

var hasGrowl = false;
const hasGrowl = false;
module.exports = function(growlConfig, cb) {
if (typeof cb === 'undefined') {
cb = growlConfig;
growlConfig = {};
}
if (hasGrowl) return cb(null, hasGrowl);
var port = growlConfig.port || 23053;
var host = growlConfig.host || 'localhost';
var socket = net.connect(port, host);
const port = growlConfig.port || 23053;
const host = growlConfig.host || 'localhost';
const socket = net.connect(port, host);
socket.setTimeout(100);

socket.once('connect', function() {
Expand Down
74 changes: 37 additions & 37 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var shellwords = require('shellwords');
var cp = require('child_process');
var semver = require('semver');
var isWSL = require('is-wsl');
var path = require('path');
var url = require('url');
var os = require('os');
var fs = require('fs');
var net = require('net');
const shellwords = require('shellwords');
const cp = require('child_process');
const semver = require('semver');
const isWSL = require('is-wsl');
const path = require('path');
const url = require('url');
const os = require('os');
const fs = require('fs');
const net = require('net');

const BUFFER_SIZE = 1024;

Expand All @@ -16,19 +16,19 @@ function clone(obj) {

module.exports.clone = clone;

var escapeQuotes = function (str) {
const escapeQuotes = function (str) {
if (typeof str === 'string') {
return str.replace(/(["$`\\])/g, '\\$1');
} else {
return str;
}
};

var inArray = function (arr, val) {
const inArray = function (arr, val) {
return arr.indexOf(val) !== -1;
};

var notifySendFlags = {
const notifySendFlags = {
u: 'urgency',
urgency: 'urgency',
t: 'expire-time',
Expand Down Expand Up @@ -90,7 +90,7 @@ module.exports.fileCommandJson = function (notifier, options, cb) {
if (!stdout) return cb(error, {});

try {
var data = JSON.parse(stdout);
const data = JSON.parse(stdout);
cb(!stderr ? null : stderr, data);
} catch (e) {
cb(e, stdout);
Expand Down Expand Up @@ -131,7 +131,7 @@ function notifierExists(notifier, cb) {
});
}

var mapAppIcon = function (options) {
const mapAppIcon = function (options) {
if (options.appIcon) {
options.icon = options.appIcon;
delete options.appIcon;
Expand All @@ -140,7 +140,7 @@ var mapAppIcon = function (options) {
return options;
};

var mapText = function (options) {
const mapText = function (options) {
if (options.text) {
options.message = options.text;
delete options.text;
Expand All @@ -149,7 +149,7 @@ var mapText = function (options) {
return options;
};

var mapIconShorthand = function (options) {
const mapIconShorthand = function (options) {
if (options.i) {
options.icon = options.i;
delete options.i;
Expand All @@ -168,7 +168,7 @@ module.exports.mapToNotifySend = function (options) {
if (options.wait === true) {
options['expire-time'] = 5; // 5 seconds default time (multipled below)
}
for (var key in options) {
for (const key in options) {
if (key === 'message' || key === 'title') continue;
if (options.hasOwnProperty(key) && notifySendFlags[key] !== key) {
options[notifySendFlags[key]] = options[key];
Expand Down Expand Up @@ -256,8 +256,8 @@ module.exports.actionJackerDecorator = function (emitter, options, fn, mapper) {
}

return function (err, data) {
var resultantData = data;
var metadata = {};
let resultantData = data;
let metadata = {};
// Allow for extra data if resultantData is an object
if (resultantData && typeof resultantData === 'object') {
metadata = resultantData;
Expand All @@ -278,27 +278,27 @@ module.exports.actionJackerDecorator = function (emitter, options, fn, mapper) {
fn.apply(emitter, [err, resultantData, metadata]);
if (!mapper || !resultantData) return;

var key = mapper(resultantData);
const key = mapper(resultantData);
if (!key) return;
emitter.emit(key, emitter, options, metadata);
};
};

module.exports.constructArgumentList = function (options, extra) {
var args = [];
const args = [];
extra = extra || {};

// Massive ugly setup. Default args
var initial = extra.initial || [];
var keyExtra = extra.keyExtra || '';
var allowedArguments = extra.allowedArguments || [];
var noEscape = extra.noEscape !== undefined;
var checkForAllowed = extra.allowedArguments !== undefined;
var explicitTrue = !!extra.explicitTrue;
var keepNewlines = !!extra.keepNewlines;
var wrapper = extra.wrapper === undefined ? '"' : extra.wrapper;

var escapeFn = function escapeFn(arg) {
const initial = extra.initial || [];
const keyExtra = extra.keyExtra || '';
const allowedArguments = extra.allowedArguments || [];
const noEscape = extra.noEscape !== undefined;
const checkForAllowed = extra.allowedArguments !== undefined;
const explicitTrue = !!extra.explicitTrue;
const keepNewlines = !!extra.keepNewlines;
const wrapper = extra.wrapper === undefined ? '"' : extra.wrapper;

const escapeFn = function escapeFn(arg) {
if (isArray(arg)) {
return removeNewLines(arg.map(escapeFn).join(','));
}
Expand All @@ -315,7 +315,7 @@ module.exports.constructArgumentList = function (options, extra) {
initial.forEach(function (val) {
args.push(escapeFn(val));
});
for (var key in options) {
for (const key in options) {
if (
options.hasOwnProperty(key) &&
(!checkForAllowed || inArray(allowedArguments, key))
Expand All @@ -330,7 +330,7 @@ module.exports.constructArgumentList = function (options, extra) {
};

function removeNewLines(str) {
var excapedNewline = process.platform === 'win32' ? '\\r\\n' : '\\n';
const excapedNewline = process.platform === 'win32' ? '\\r\\n' : '\\n';
return str.replace(/\r?\n/g, excapedNewline);
}

Expand All @@ -350,7 +350,7 @@ function removeNewLines(str) {
[-application] <C:\foo.exe> | Provide a application that might be started if the pipe does not exist.
-close <id> | Closes a currently displayed notification.
*/
var allowedToasterFlags = [
const allowedToasterFlags = [
't',
'm',
'b',
Expand All @@ -365,8 +365,8 @@ var allowedToasterFlags = [
'close',
'install'
];
var toasterSoundPrefix = 'Notification.';
var toasterDefaultSound = 'Notification.Default';
const toasterSoundPrefix = 'Notification.';
const toasterDefaultSound = 'Notification.Default';
module.exports.mapToWin8 = function (options) {
options = mapAppIcon(options);
options = mapText(options);
Expand Down Expand Up @@ -437,7 +437,7 @@ module.exports.mapToWin8 = function (options) {
delete options.actions;
}

for (var key in options) {
for (const key in options) {
// Check if is allowed. If not, delete!
if (
options.hasOwnProperty(key) &&
Expand Down
38 changes: 19 additions & 19 deletions notifiers/balloon.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ Usage
4 = Closed or faded out
*/
var path = require('path');
var notifier = path.resolve(__dirname, '../vendor/notifu/notifu');
var checkGrowl = require('../lib/checkGrowl');
var utils = require('../lib/utils');
var Toaster = require('./toaster');
var Growl = require('./growl');
var os = require('os');
const path = require('path');
const notifier = path.resolve(__dirname, '../vendor/notifu/notifu');
const checkGrowl = require('../lib/checkGrowl');
const utils = require('../lib/utils');
const Toaster = require('./toaster');
const Growl = require('./growl');
const os = require('os');

var EventEmitter = require('events').EventEmitter;
var util = require('util');
const EventEmitter = require('events').EventEmitter;
const util = require('util');

var hasGrowl;
let hasGrowl;

module.exports = WindowsBalloon;

Expand All @@ -51,16 +51,16 @@ util.inherits(WindowsBalloon, EventEmitter);

function noop() {}
function notifyRaw(options, callback) {
var fallback;
var notifierOptions = this.options;
let fallback;
const notifierOptions = this.options;
options = utils.clone(options || {});
callback = callback || noop;

if (typeof options === 'string') {
options = { title: 'node-notifier', message: options };
}

var actionJackedCallback = utils.actionJackerDecorator(
const actionJackedCallback = utils.actionJackerDecorator(
this,
options,
callback,
Expand Down Expand Up @@ -114,23 +114,23 @@ Object.defineProperty(WindowsBalloon.prototype, 'notify', {
}
});

var allowedArguments = ['t', 'd', 'p', 'm', 'i', 'e', 'q', 'w', 'xp'];
const allowedArguments = ['t', 'd', 'p', 'm', 'i', 'e', 'q', 'w', 'xp'];

function doNotification(options, notifierOptions, callback) {
var is64Bit = os.arch() === 'x64';
const is64Bit = os.arch() === 'x64';
options = options || {};
options = utils.mapToNotifu(options);
options.p = options.p || 'Node Notification:';

var fullNotifierPath = notifier + (is64Bit ? '64' : '') + '.exe';
var localNotifier = notifierOptions.customPath || fullNotifierPath;
const fullNotifierPath = notifier + (is64Bit ? '64' : '') + '.exe';
const localNotifier = notifierOptions.customPath || fullNotifierPath;

if (!options.m) {
callback(new Error('Message is required.'));
return this;
}

var argsList = utils.constructArgumentList(options, {
const argsList = utils.constructArgumentList(options, {
wrapper: '',
noEscape: true,
explicitTrue: true,
Expand All @@ -139,7 +139,7 @@ function doNotification(options, notifierOptions, callback) {

if (options.wait) {
return utils.fileCommand(localNotifier, argsList, function(error, data) {
var action = fromErrorCodeToAction(error.code);
const action = fromErrorCodeToAction(error.code);
if (action === 'error') return callback(error, data);

return callback(null, action);
Expand Down
16 changes: 8 additions & 8 deletions notifiers/growl.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
* Wrapper for the growly module
*/
var checkGrowl = require('../lib/checkGrowl');
var utils = require('../lib/utils');
var growly = require('growly');
const checkGrowl = require('../lib/checkGrowl');
const utils = require('../lib/utils');
const growly = require('growly');

var EventEmitter = require('events').EventEmitter;
var util = require('util');
const EventEmitter = require('events').EventEmitter;
const util = require('util');

var errorMessageNotFound =
const errorMessageNotFound =
"Couldn't connect to growl (might be used as a fallback). Make sure it is running";

module.exports = Growl;

var hasGrowl;
let hasGrowl;

function Growl(options) {
options = utils.clone(options || {});
Expand Down Expand Up @@ -58,7 +58,7 @@ function notifyRaw(options, callback) {
options.title = options.title || 'Node Notification:';

if (hasGrowl || !!options.wait) {
var localCallback = options.wait ? callback : noop;
const localCallback = options.wait ? callback : noop;
growly.notify(options.message, options, localCallback);
if (!options.wait) callback();
return this;
Expand Down
Loading

0 comments on commit 1265ee3

Please sign in to comment.