withReporter.js 767 B

1234567891011121314151617181920212223242526272829303132333435
  1. var PluginError = require('plugin-error');
  2. var api = require("./extra_api");
  3. var notify = require("./notify");
  4. module.exports = function (reporter) {
  5. if (!reporter) throw new PluginError("gulp-notify", "No custom reporter defined.");
  6. var inner = function (options) {
  7. options = setOptions(options, reporter);
  8. return notify(options);
  9. };
  10. inner.onError = function (options) {
  11. options = setOptions(options, reporter);
  12. return api.onError(options);
  13. };
  14. inner.logLevel = api.logLevel;
  15. inner.logger = api.logger;
  16. return inner;
  17. };
  18. function setOptions (options, reporter) {
  19. options = options || {};
  20. if (typeof options !== "object") {
  21. options = {
  22. message: options
  23. };
  24. }
  25. options.notifier = reporter;
  26. return options;
  27. }