Beispiel #1
0
module.exports.onError = function (options, callback) {
  var reporter;
  options = options || {};
  var templateOptions = options.templateOptions || {};
  var callback = callback || function (err) {
    err && logError({
      title: "Error running notifier",
      message: "Could not send message: " + err.message
    }, true);
  };

  if (options.notifier) {
    reporter = options.notifier;
  } else {
    if (options.host || options.appName || options.port) {
      notifier = new notifier.Notification({
        host: options.host || 'localhost',
        appName: options.appName || 'gulp-notify',
        port: options.port || '23053'
      });
    }
    reporter = notifier.notify.bind(notifier);
  }
  return function (error) {
    var self = this;
    report(reporter, error, options, templateOptions, function () {
      callback.apply(self, arguments);
      self.emit && self.emit('end');
    });
  };
};
Beispiel #2
0
const Application = require('thinkjs');
const babel = require('think-babel');
const watcher = require('think-watcher');
const notifier = require('node-notifier');
require('ipfs');
const series = require('async-series');
const instance = new Application({
  ROOT_PATH: __dirname,
  watcher: watcher,
  transpiler: [babel, {
    presets: ['think-node']
  }],
  notifier: notifier.notify.bind(notifier),
  env: 'development'
});

instance.run();
Beispiel #3
0
module.exports = function (options) {
  var reporter;
  var lastFile = null;

  options = options || {};
  var templateOptions = options.templateOptions || {};

  if (options.notifier) {
    reporter = options.notifier;
  } else {
    if (options.host || options.appName || options.port) {
      notifier = new notifier.Notification({
        host: options.host,
        appName: options.appName,
        port: options.port
      });
    }
    reporter = notifier.notify.bind(notifier);
  }

  function notify (file, enc, callback) {
    var stream = this;

    report(reporter, file, options, templateOptions, function (err) {
      logError(err, stream);

      if (options.emitError) {
        stream.push(file);
        return callback();
      }
    });

    if (!options.emitError) {
      stream.push(file);
      return callback();
    }
  }

  if (!options.onLast) {
    return through.obj(notify);
  }

  // Only send notification on the last file.
  return through.obj(function (file, enc, callback) {
    lastFile = file;
    this.push(file);
    callback();
  }, function (callback) {
    var stream = this;

    if (!lastFile) {
      return callback();
    }

    report(reporter, lastFile, options, templateOptions, function (err) {
      logError(err, stream);
      if (options.emitError) {
        return callback();
      }
    });

    lastFile = null; // reset
    if (!options.emitError) {
      return callback();
    }
  });

  function logError (err, stream) {
    if (!err) return;

    var isGrowl = notifier && notifier instanceof notifier.Growl;
    var isEcon = err.message.indexOf('ECONNREFUSED') !== -1;
    var dropMessage = isGrowl && isEcon;

    if (dropMessage) {
      return extra.logError({
        title: 'Info',
        message: 'No notification system installed.'
      });
    }

    if (options.emitError) return stream.emit('error', err);

    extra.logError({
      title: 'Error in notifier',
      message: err
    }, true);
  }
};