Files
login/node_modules/node-notifier/notifiers/notificationcenter.js
Amruta Kawade 45b10ffd19 Adding node_modules for dependabot (#67)
* Bump lodash from 4.17.15 to 4.17.19 (#52)

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com>

* Bump @actions/core from 1.1.3 to 1.2.6 (#60)

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.1.3 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com>

* updating node_nodules

* updated package-lock

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-12 14:58:40 +05:30

101 lines
2.4 KiB
JavaScript

/**
* A Node.js wrapper for terminal-notify (with fallback).
*/
var utils = require('../lib/utils');
var Growl = require('./growl');
var path = require('path');
var notifier = path.join(
__dirname,
'../vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier'
);
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var errorMessageOsX =
'You need Mac OS X 10.8 or above to use NotificationCenter,' +
' or use Growl fallback with constructor option {withFallback: true}.';
module.exports = NotificationCenter;
function NotificationCenter(options) {
options = utils.clone(options || {});
if (!(this instanceof NotificationCenter)) {
return new NotificationCenter(options);
}
this.options = options;
EventEmitter.call(this);
}
util.inherits(NotificationCenter, EventEmitter);
var activeId = null;
function noop() {}
NotificationCenter.prototype.notify = function(options, callback) {
var fallbackNotifier;
var id = identificator();
options = utils.clone(options || {});
activeId = id;
if (typeof options === 'string') {
options = { title: 'node-notifier', message: options };
}
callback = callback || noop;
if (typeof callback !== 'function') {
throw new TypeError(
'The second argument must be a function callback. You have passed ' +
typeof fn
);
}
var actionJackedCallback = utils.actionJackerDecorator(
this,
options,
callback,
function(data) {
if (activeId !== id) return false;
if (data === 'activate') {
return 'click';
}
if (data === 'timeout') {
return 'timeout';
}
if (data === 'replied') {
return 'replied';
}
return false;
}
);
options = utils.mapToMac(options);
if (!options.message && !options.group && !options.list && !options.remove) {
callback(new Error('Message, group, remove or list property is required.'));
return this;
}
var argsList = utils.constructArgumentList(options);
if (utils.isMountainLion()) {
utils.fileCommandJson(
this.options.customPath || notifier,
argsList,
actionJackedCallback
);
return this;
}
if (fallbackNotifier || !!this.options.withFallback) {
fallbackNotifier = fallbackNotifier || new Growl(this.options);
return fallbackNotifier.notify(options, callback);
}
callback(new Error(errorMessageOsX));
return this;
};
function identificator() {
return { _ref: 'val' };
}