Last active
January 2, 2016 13:49
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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