Skip to content

Instantly share code, notes, and snippets.

@mikaelbr
Last active January 2, 2016 13:49
Show Gist options
  • Save mikaelbr/8313072 to your computer and use it in GitHub Desktop.
Save mikaelbr/8313072 to your computer and use it in GitHub Desktop.
prototype/proof of concept: A mac notification tool for Gulp. See https://github.com/mikaelbr/gulp-notify for full code
// From prototype/proof of concept. See https://github.com/mikaelbr/gulp-notify for full code
var es = require("event-stream"),
path = require("path"),
result = require("lodash.result"),
notifier = require("node-notifier");
module.exports = function (options) {
"use strict";
function notify(file, callback) {
var message = "", title = "Gulp notification";
if (!options) {
callback(new Error("gulp-notify: No message, function or object passed - no notification to give"), undefined);
}
if (typeof options === "function") {
message = options(file);
}
if (typeof options === "object") {
title = result(options, "title") || title;
message = result(options, "message") || message;
}
if (typeof options === "string") {
message = options;
}
notifier.notify({
title: title,
message: message
}, callback);
}
return es.map(notify);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment