HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/zaklada/html/node_modules/gulp-notify/lib/report.js
var template = require("lodash.template");
var PluginError = require('plugin-error');
var api = require("./extra_api");
var extend = require("node.extend");
var path = require("path");

"use strict";

var defaults = {
  error: {
    icon: path.join(__dirname, '..', 'assets', 'gulp-error.png'),
    sound: 'Frog'
  },
  regular: {
    icon: path.join(__dirname, '..', 'assets', 'gulp.png')
  }
};


module.exports = function (reporter, message, options, templateOptions, callback) {
  var self = this;
  callback = callback || function () {};
  if (!reporter) return callback(new PluginError("gulp-notify", "No reporter specified."));

  // Try/catch the only way to go to ensure catching all errors? Domains?
  try {
    var options = constructOptions(options, message, templateOptions);
    if (!options) {
      return callback();
    }
    api.logError(options, (message instanceof Error));
    reporter(options, function (err) {
      if (err) return callback(new PluginError("gulp-notify", err));
      return callback();
    });
  } catch (err) {
    return callback(new PluginError("gulp-notify", err));
  }
};

function generate (outputData, object, title, message, subtitle, open, templateOptions) {
  if (object instanceof Error) {
    var titleTemplate = template(title);
    var messageTemplate = template(message);
    var openTemplate = template(open);
    var subtitleTemplate = template(subtitle);

    return extend(defaults.error, outputData, {
      title: titleTemplate({
        error: object,
        options: templateOptions
      }),
      message: messageTemplate({
        error: object,
        options: templateOptions
      }),
      open: openTemplate({
        error: object,
        options: templateOptions
      }),
      subtitle: subtitleTemplate({
        error: object,
        options: templateOptions
      })
    });
  }

  return extend(defaults.regular, outputData, {
    title: template(title)({
      file: object,
      options: templateOptions
    }),
    message: template(message)({
      file: object,
      options: templateOptions
    })
  });
}

function constructOptions (options, object, templateOptions) {
  var message = object.path || object.message || object,
      title = !(object instanceof Error) ? "Gulp notification" : "Error running Gulp",
      open = "",
      subtitle = "",
      outputData = {};

  if (typeof options === "function") {
    message = options(object);
    if (typeof message === "object") {
      options = message;
    }
    if (!message) {
      return false;
    }
  }

  if (typeof options === "string") {
    message = options;
  }

  if (typeof options === "object") {
    outputData = extend(true, {}, options);
    if (typeof outputData.title === "function") {
      title = outputData.title(object);
    } else {
      title = outputData.title || title;
    }

    if (typeof outputData.subtitle === "function") {
      subtitle = outputData.subtitle(object);
    } else {
      subtitle = outputData.subtitle || subtitle;
    }

    if (typeof outputData.open === "function") {
      open = outputData.open(object);
    } else {
      open = outputData.open || open;
    }

    if (typeof outputData.message === "function") {
      message = outputData.message(object);
      if (!message) {
        return false;
      }
    } else {
      message = outputData.message || message;
    }
  }
  return generate(outputData, object, title, message, subtitle, open, templateOptions);
}