Giter Site home page Giter Site logo

mikaelbr / gulp-notify Goto Github PK

View Code? Open in Web Editor NEW
594.0 12.0 39.0 820 KB

gulp plugin to send messages based on Vinyl Files or Errors to Mac OS X, Linux or Windows using the node-notifier module. Fallbacks to Growl or simply logging

License: MIT License

JavaScript 100.00%

gulp-notify's Introduction

gulp-notify NPM version Build Status Dependency Status

notification plugin for gulp

Information

Package gulp-notify
Description Send messages to Mac Notification Center, Linux notifications (using notify-send) or Windows >= 8 (using native toaster) or Growl as fallback, using the node-notifier module. Can also specify custom notifier.
Node Version >= 0.8

Table of Contents

Requirements

  • Mac OS X: No external installation needed (if Mac OS X 10.8 or higher).
  • Linux: notify-send/notify-osd should be installed (On Ubuntu this is installed per default)
  • Windows: Uses native toaster (if Windows 8 or higher).
  • Fallback: Growl: Growl (for Mac, Windows or similar) should be installed.

See node-notifier for details.

Windows 10 Note: You might have to activate banner notification for the toast to show.

From #90 (comment)

You can make it work by going to System > Notifications & Actions. The 'toast' app needs to have Banners enabled. (You can activate banners by clicking on the 'toast' app and setting the 'Show notification banners' to On)

Usage

First, install gulp-notify as a development dependency:

npm install --save-dev gulp-notify

Then, add it to your gulpfile.js:

var notify = require("gulp-notify");
gulp.src("./src/test.ext")
  .pipe(notify("Hello Gulp!"));

Or with template

var notify = require("gulp-notify");
gulp.src("./src/test.ext")
  .pipe(notify("Found file: <%= file.relative %>!"));

See examples for more or the API section for various inputs.

Notes/tip

gulp-notify passes on the vinyl files even on error. So if you are using gulp-plumber the run will not break if the notifier returns an error.

If you want to notify on errors gulp-plumber can be used to not break the run and force you to have to restart gulp.

You can use notify.onError() as the errorHandler for gulp-plumber like this:

gulp.src("../test/fixtures/*")
      .pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
      .pipe(through(function () {
        this.emit("error", new Error("Something happend: Error message!"))
      }));

API

notify(String)

A message to notify per data on stream. The string can be a lodash template as it is passed through gulp-util.template.

notify(Function)

Type: function(VinylFile)

Vinyl File from gulp stream passed in as argument.

The result of the function can be a string used as the message or an options object (see below). If the returned value is a string, it can be a lodash template as it is passed through gulp-util.template.

If false is returned from the function the notification won't run.

notify(options)

*Options are passed onto the reporter, so on Windows, you can define Growl host, on Mac you can pass in contentImage, and so on.

See node-notifier for all options*

Default notification values:

  • Gulp logo on regular notification
  • Inverted Gulp logo on error
  • Frog sound on error on Mac.

See also the advanced example.

options.onLast

Type: Boolean Default: false

If the notification should only happen on the last file of the stream. Per default a notification is triggered on each file.

options.emitError

Type: Boolean Default: false

If the returned stream should emit an error or not. If emitError is true, you have to handle .on('error') manually in case the notifier (gulp-notify) fails. If the default false is set, the error will not be emitted but simply printed to the console.

This means you can run the notifier on a CI system without opting it out but simply letting it fail gracefully.

options.message

Type: String Default: File path in stream

The message you wish to attach to file. The string can be a lodash template as it is passed through gulp-util.template.

Example: Created <%= file.relative %>.

as function

Type: Function(vinylFile)

See notify(Function).

options.title

Type: String Default: "Gulp Notification"

The title of the notification. The string can be a lodash template as it is passed through gulp-util.template.

Example: Created <%= file.relative %>.

as function

Type: Function(vinylFile)

See notify(Function).

options.templateOptions

Type: Object Default: {}

Object passed to the lodash template, for additional properties passed to the template.

Examples:

gulp.src("../test/fixtures/*")
    .pipe(notify({
      message: "Generated file: <%= file.relative %> @ <%= options.date %>",
      templateOptions: {
        date: new Date()
      }
    }))

options.notifier

Type: Function(options, callback) Default: node-notifier module

Swap out the notifier by passing in an function. The function expects two arguments: options and callback.

The callback must be called when the notification is finished. Options will contain both title and message.

See notify.withReporter for syntactic sugar.

notify.on(event, function (notificationOptions)) - Events

If the wait option is set to true, the notifier will trigger events click or timeout, whether the user clicks the notification or it times out. You listen to these events on the main notify object, not the produces stream.

var notify = require('gulp-notify');

notify.on('click', function (options) {
  console.log('I clicked something!', options);
});

notify.on('timeout', function (options) {
  console.log('The notification timed out', options);
});

gulp.task("click", function () {
  return gulp.src("some/glob/**")
    .pipe(notify({ message: 'Click or wait', wait: true }));
});

notify.withReporter(Function)

Type: Reporter

Wraps options.notifier to return a new notify-function only using the passed in reporter.

Example:

var custom = notify.withReporter(function (options, callback) {
  console.log("Title:", options.title);
  console.log("Message:", options.message);
  callback();
});

gulp.src("../test/fixtures/1.txt")
    .pipe(custom("This is a message."));

This will be the same as

gulp.src("../test/fixtures/1.txt")
    .pipe(notify({
      message: "This is a message."
      notifier: function (options, callback) {
        console.log("Title:", options.title);
        console.log("Message:", options.message);
        callback();
      }
    }));

But much, much prettier.

notify.onError()

The exact same API as using notify(), but where a vinyl File is passed, the error object is passed instead.

Example:

gulp.src("../test/fixtures/*")
      .pipe(through(function () {
        this.emit("error", new Error("Something happend: Error message!"))
      }))
      .on("error", notify.onError(function (error) {
        return "Message to the notifier: " + error.message;
      }));

Or simply:

gulp.src("../test/fixtures/*")
      .pipe(through(function () {
        this.emit("error", new Error("Something happend: Error message!"))
      }))
      .on("error", notify.onError("Error: <%= error.message %>"));
gulp.src("../test/fixtures/*")
      .pipe(through(function () {
        this.emit("error", new Error("Something happend: Error message!"))
      }))
      .on("error", notify.onError({
        message: "Error: <%= error.message %>",
        title: "Error running something"
      }));

The onError() end point does support lodash.template.

onError() will automatically end the stream for you. Making it easer for watching.

notify.logLevel(level)

Type: Integer Default: 2

Set if logger should be used or not. If log level is set to 0, no logging will be used. If no new log level is passed, the current log level is returned.

  • 0: No logging
  • 1: Log on error
  • 2: Log both on error and regular notification.

If logging is set to > 0, the title and message passed to gulp-notify will be logged like so:

➜  gulp-notify git:(master) ✗ gulp --gulpfile examples/gulpfile.js one
[gulp] Using file /Users/example/gulp-notify/examples/gulpfile.js
[gulp] Working directory changed to /Users/example/repos/gulp-notify/examples
[gulp] Running 'one'...
[gulp] Finished 'one' in 4.08 ms
[gulp] gulp-notify: [Gulp notification] /Users/example/gulp-notify/test/fixtures/1.txt

Disable gulp-notify

If you are running on a system that handles notifications poorly or you simply do not wish to use gulp-notify but your project does? You can disable gulp-notify by using enviroment variable DISABLE_NOTIFIER.

export DISABLE_NOTIFIER=true;

This will disable all methods; notify(), notify.onError and notify.withReporter.

Examples

To see all examples run from root:

$ gulp --gulpfile examples/gulpfile.js --tasks
[gulp] Using file /Users/example/gulp-notify/examples/gulpfile.js
[gulp] Working directory changed to /Users/example/gulp-notify/examples
[gulp] Tasks for /Users/example/gulp-notify/examples/gulpfile.js
[gulp] ├── multiple
[gulp] ├── one
[gulp] ├── message
[gulp] ├── customReporter
[gulp] ├── template
[gulp] ├── templateadv
[gulp] ├── function
[gulp] ├── onlast
[gulp] ├── advanceMac
[gulp] ├── error
[gulp] ├── forceGrowl
[gulp] └── customError

To run an example:

$ gulp --gulpfile examples/gulpfile.js multiple
[gulp] Using file /Users/example/gulp-notify/examples/gulpfile.js
[gulp] Working directory changed to /Users/example/gulp-notify/examples
[gulp] Running 'multiple'...
[gulp] Finished 'multiple' in 3.75 ms

As jshint reporter

gulp-notify can easily be used as jshint reporter. As jshint exposes the result on the vinyl file we can use them in a function like so:

gulp.task('lint', function() {
  gulp.src('/src/**/*.js')
    .pipe(jshint())
    // Use gulp-notify as jshint reporter
    .pipe(notify(function (file) {
      if (file.jshint.success) {
        // Don't show something if success
        return false;
      }

      var errors = file.jshint.results.map(function (data) {
        if (data.error) {
          return "(" + data.error.line + ':' + data.error.character + ') ' + data.error.reason;
        }
      }).join("\n");
      return file.relative + " (" + file.jshint.results.length + " errors)\n" + errors;
    }));
});

If you use a function for message in gulp-notify, the message won't be shown. This is true for both direct use of function and { message: function () {}}.

NPM downloads

License

MIT License

gulp-notify's People

Contributors

andorbal avatar codepunkt avatar eiriksm avatar jparkerweb avatar leonardodino avatar mathroc avatar mbriggs avatar mikaelbr avatar mollerse avatar mrdinckleman avatar ohbarye avatar queicherius avatar stevelacy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gulp-notify's Issues

Not firing on Plumber Error

I'm having issues with getting notify working on a plumber error. I tried the example code with no luck. Then I tried Node-Notification, which worked. So then I swapped out their notification code which a simple notify message found in the gist below. Also no luck.

https://gist.github.com/jmisavage/32cc074bafabff79bbcc

I know its probably something silly, I just can't figure it out.

Ubuntu 14.04 LTS unhandled 'error' event

Hi, I started to use gulp-notify it is really useful, but when I run gulp it sometimes work, but most of the time I get in my console an error, I really don't know why.

This is my gulpfile.js

var gulp = require('gulp');

// Tests
var phpspec = require('gulp-phpspec');
var run = require('gulp-run');
var notify = require('gulp-notify');

/*
|--------------------------------------------------------------------------
| Test Tasks
|--------------------------------------------------------------------------
| This tasks trigger tests of PhpSpec on Save
*/
gulp.task('test', function() {
    gulp.src('spec/**/*.php')
        .pipe(run('clear'))
        .pipe(phpspec('', { notify: true }))
        .on('error', notify.onError({
            title: 'Hey Fabri!!',
            message: 'Your tests failed!',
            icon: __dirname + '/fail.png'
        }))
        .pipe(notify({
            title: 'Amazing Fabri!',
            message: 'All tests have returned green!',
            icon: __dirname + '/success.png'
        }));
});

// Watcher
gulp.task('watch', function() {
    gulp.watch(['spec/**/*.php', 'app/**/*.php'], ['test']);
});

// Default Tasks
gulp.task('default', ['test', 'watch']);

The error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: write EPIPE
    at errnoException (net.js:901:11)
    at Object.afterWrite (net.js:718:19)

If you can help me to fix this issue will be fantastic! Thanks

Invoke notify() directly?

In my use case, I want to invoke notify() directly within my handlers, currently I'm doing something like this:

function callback(err){
gulp.src('').pipe( notify('Gulp Errors ') )
}

Is there anyway to invoke notify('xxx') directly? thanks.

No growl notification in plumber errorHandler

This is a part of my gulpfile:

// Copy
gulp.task('copy', ['clean'], function () {
  // event-stream
  return es.concat(

    // copy js files
    gulp.src(['source/js/**/*.js'])
      .pipe(plumber({errorHandler: onError}))
      .pipe(uglify({"mangle": false}))
      .pipe(gulp.dest('build/js')),
   ...

var onError = function (err) {
  gutil.log('======= ERROR. ========\n')
  notify("ERROR: " + err.plugin); // for growl
  gutil.beep();
};

i see "===ERROR===" message in console and gutil.beep() works but i see no growl notification. why?

Error in notifier with terminal-notifier

Hello

From time to time (about 1 notification on 3) I got the following error:

[15:21:11] Starting 'scripts'...
[15:21:12] gulp-notify: [Gulp notification] survey.js built
[15:21:12] gulp-notify: [Gulp notification] main.js built
[15:21:12] Finished 'scripts' after 1.1 s
[15:21:12] gulp-notify: [Error in notifier] Error in plugin 'gulp-notify'
2014-10-01 15:21:12.682 terminal-notifier[70397:d07] In 'CFPasteboardCopyDataReturn __CFPasteboardCopyData(CFPasteboardRef, CFIndex, CFIndex, CFStringRef, Boolean, Boolean)', file /SourceCache/CF/CF-855.17/AppServices.subproj/CFPasteboard.c, line 2953, during unlock, spin lock 0x10b986d08 has value 0x0, which is not locked.  The memory has been smashed or the lock is being unlocked when not locked.

Did I made something wrong ?

Notify about compilation errors

Is it possible to have it emit notification when sass compilation fails in a watcher like this:

gulp.task('default', function () {
  server.listen(35729, function (err) {
    if (err) return console.log(err);

    gulp.watch('sass/**/*.scss', function () {
        gulp.run('sass');
    });
  });
});

Feature Request: Native Windows 8 notifications

Currently I am able to use the plugin without hassle on Windows via Growl - however other team members at work don't want to install Growl just for notifications, it would be awesome if Windows 8 native notifications could be supported.

I'm pretty sure there is an existing node module for Win 8 notifications - but as a mere web developer only recently introduced to NodeJS, I wouldn't have a clue on how to implement it myself!

Fail gracefully on notification error.

From @jingchan mikaelbr/node-notifier#8

Getting "ECONNREFUSED" errors on my Windows 8.1 machine when growl for windows is not installed.

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: connect ECONNREFUSED
    at errnoException (net.js:904:11)
    at Object.afterConnect [as oncomplete] (net.js:895:19)

It'd be nice to preserve gulp-notify's console output functionality while making external notification programs optional. (E.g. I'm a fan of the notification systems available on OS X, but am not a fan of Growl for Windows.)

So far I've hacked around it by adding:

.on('error', function(e){
  console.log("No notification center found");
})

“gulp-notify: [Error running Gulp] Error: write after end”

I get this message on Windows 8 (not tried on any other OS) when saving a JavaScript-file. gulp-notify still runs after the message, but stops triggering on subsequent saves.

I only get this error on the JavaScript section of the gulp setup for the project that I work on – it doesn’t fail when saving LESS-files.

Window support

hello,

i was wondering if supporting windows in some way would be an actual possibility. even exclude the plugin execution would be nicer than let node crashes ungracefully.

thanks.

Keep plumber logging to console

Is it possible to have gulp-notify catch errors and at same time keep gulp-plumber console logging? Basically I want to be notified when something breaks and if I go to the terminal I still want to see plumber's nicely formatted log.

App icon support

Noticed the latest version:

"v1.3.1
Updates node-notifier dependency. Adds support for app icon and images for Mac."

Does this mean rather than the terminal icon showing up I can customise it to show something else? Can't find any docs on how to do this?

gulp-notify + windows 7 running synchronized with my task

Hello and thank you very much for your work in gulp-notify.

I have a problem with your most recent version of this plugin. I used to work with snarl or growl but the most recent version uses the native windows notifier.

My problem is that my task will not finish or continue unless I click the 'x' button on the notification to close it. I have not found any option to disable this.

Any help would be much appreciated.
Thanks again!

error in plugin 'gulp-notify': connect econnrefused

Every time after the notification printed to the console, this error occurs.

I run it on Windows 7 with Node v0.10.21. The code is simple:

var gulp = require('gulp'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    notify = require('gulp-notify'),
    livereload = require('gulp-livereload'),
    server = require('tiny-lr')();

// Scripts
gulp.task('scripts', function() {
  return gulp.src('public/js/*.js')
    .pipe(concat('all.js'))
    .pipe(gulp.dest('public/dist/js'))
    .pipe(rename({ suffix: '.min' }))
    .pipe(uglify())
    .pipe(livereload(server))
    .pipe(gulp.dest('public/dist/js'))
    .pipe(notify({ message: 'Scripts task complete' }));
});

gulp.task('default', function() {
    gulp.start('scripts');
});

onError with growl

Hello,

in case my tasks crash (e.g. coffe-script or handlebars compilation) I want to show the errors via growl notifications. I've added a customer reporter using the growl from node-notifier (normal notifications work using this):

growl = notify.withReporter (options, cb) ->
  nn.Growl().notify options
  cb()

For errors in coffee-script compilation I've chained the on-event to notify.onError, like this (also note that I use plumber to continue my watch task):

[...]
.pipe(plumber())
.pipe(coffee({bare: true}).on "error", notify.onError("!")
[...]

On the console I can see that obviously the error gets triggered:

gulp-notify: [Error running Gulp] Message to the notifier: ...

But there is no growl notification for the error. Any thoughts on this?

Thanks, BR, toovy

gulp-notify breaks Travis CI

Here is an excerpt from the log of a failing Travis CI build:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Command failed: /bin/sh: 1: notify-send: not found
    at ChildProcess.exithandler (child_process.js:637:15)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Socket.<anonymous> (child_process.js:956:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

The command "gulp ci" exited with 8.

Done. Your build exited with 1.

Is this a gulp-notify-bug or is there some workaround to prevent it from running/failing on Travis or similar Linux-systems without notify-send installed?

onLast - option gives error

Using onLast will give an error.

        .pipe(notify({
            onLast:true,
            title: 'Stylus Task',
            message: 'Stylus Compiled'
        }));

removing onLast works as expected.

error:

 node_modules/gulp-notify/node_modules/node-notifier/lib/utils.js:7
  return str.replace(/\"/g, '\\"');
             ^
TypeError: Object true has no method 'replace'
    at escapeQuotes (node_modules/gulp-notify/node_modules/node-notifier/lib/utils.js:7:14)
    at Object.module.exports.constructArgumentList (node_modules/gulp-notify/node_modules/node-notifier/lib/utils.js:31:34)

Notification won't show onError

I have been trying to implement plumber with the notify.onError function available. I don't get any notifications at all. I have even tried to use .on('error', ... ) however notifications still don't display.

If I .pipe(notify({message: 'message here'}) I get a notification.

Here is my task:

gulp.task('styles', function () {
    gulp.src(sources.sass.files)
    .pipe(plumber({errorHandler: notify.onError("Error: there was an error")}))
    .pipe(
        rubySass({ style: 'expanded', debugInfo: true, lineNumbers: true })
    )

    .pipe(gulp.dest(sources.sass.dest));
});

EDIT: Changed notification to notify on .pipe(notify)

Error and custom notifications are not displayed

I'm having trouble displaying gulp-stylus errors using gulp-notify.
I can't get it to display anything, though the error handler is working properly:
Here's my Stylus task:

gulp.task('stylus', function() {
  gulp.src('./stylesheets/*.styl')
  .pipe(stylus())
  .on('error', notify.onError('!'))
  .pipe(gulp.dest('./stylesheets'));
});

I also tried running some of the examples and looks like only those using piping into notify work, e.g. function or multiple. But those that use custom or onError don't display anything 😿

I'm using Ubuntu 13.10 if that helps.

Green icon for success message

The red default icon and inverted red error icon are not immediately clear. Could you add a green 'success' version and possible change the default icon to a slate gray or blue?

Not running Notification Center (OSX)

I have disabled the Notification Center on OSX.
How do I configure Notify to only output errors to the Terminal?

Error message:

Error in plugin 'gulp-notify': Command failed: 2014-05-28 11:22:00.178 terminal-notifier[68362:d07] [!] Unable to post a notification for the current user (ryan), as it has no running NotificationCenter instance.

Possible to disable via environment variable?

These notifications are ridiculously unusable on Linux systems running Gnome Shell, where they cause the pop-up indicator to bounce around incessantly. Those of us who don't wish to see these notifications should be able to easily disable them by dropping a line into our environment configuration.

Keep getting 'ReferenceError: exec is not defined'

I have in my gulpfile

/*globals require*/
'use strict';

var gulp = require('gulp'),
    gutil = require('gulp-util'),
    minifyCss = require('gulp-minify-css'),
    autoPrefixer = require('gulp-autoprefixer'),
    notify = require('gulp-notify'),
    less = require('gulp-less'),
    browserSync = require('browser-sync'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    lessAssetDir = 'app/assets/less',
    cssDir = 'public/css';

gulp.src(lessAssetDir + '/styles.less')
  .pipe(notify("Found file: <%= file.relative %>!"));

and when I run gulp I get

/Users/xxx/node_modules/gulp-notify/node_modules/node-notifier/lib/utils.js:14
  var notifyApp = exec(shellwords.escape(notifier) + ' ' + options.join(' '),
                  ^
ReferenceError: exec is not defined
    at Object.module.exports.command (/Users/xxx/node_modules/gulp-notify/node_modules/node-notifier/lib/utils.js:14:19)
    at /Users/xxx/node_modules/gulp-notify/node_modules/node-notifier/lib/notifiers/terminal-notifier.js:38:13
    at /Users/xxx/node_modules/gulp-notify/node_modules/node-notifier/lib/utils.js:63:14
    at ChildProcess.exithandler (child_process.js:645:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:753:16)
    at Socket.<anonymous> (child_process.js:966:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:465:12)

Package versions

$ npm -v
1.4.14

$ node -v
v0.10.28

$ gulp -v
[23:01:33] CLI version 3.7.0
[23:01:33] Local version 3.7.0

[email protected]

OSX 10.9.3

What am I doing wrong?

Error File Not Found

Any ideas?

08:22:37] gulp-notify: [Error in notifier] Error in plugin 'gulp-notify'
Command failed: /usr/lib/ruby/1.9.1/fileutils.rb:1371:in `initialize': No such file or directory - /tmp/vagrant-notify/-home-vagrant-Development-mowermatcher-node_modules-gulp-notify-assets-gulp.png

Messages should be sanitized before being passed to /bin/sh on OSX

gulp-notify is throwing an internal error when passing certain error messages on OSX.

Error message from gulp:

[gulp] gulp-notify: [Error running notifier] Could not send message: Command failed: /bin/sh: -c: line 1: syntax error near unexpected token `('
/bin/sh: -c: line 1: `Syntax error: Invalid CSS after "@mixin break ": expected "{", was "point($point) {"'

Relevant gulp entry:

gulp.task ( 'styles', function () {
    return gulp.src ( 'sass/main.scss' )
        .pipe ( $.rubySass ( {
                                 style: 'expanded',
                                 loadPath: ['vendor/bower_components']
                             } ).on("error", $.notify.onError({'title': 'rubySass' })))
        .pipe ( $.autoprefixer ( 'last 1 version' ).on("error", $.notify.onError({'title': 'autoprefixer' })) )
        .pipe ( $.csso ().on("error", $.notify.onError({'title': 'csso' })) )
        .pipe ( $.livereload () )
        .pipe ( gulp.dest ( 'public/css' ) )
        .pipe ( $.size () )

} );

Environment:
$ node --version
v0.10.26

$ npm version
{ http_parser: '1.0',
  node: '0.10.26',
  v8: '3.14.5.9',
  ares: '1.9.0-DEV',
  uv: '0.10.25',
  zlib: '1.2.3',
  modules: '11',
  openssl: '1.0.1e',
  npm: '1.4.3' }

$ npm ls | grep gulp
├─┬ [email protected]
│ ├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected] extraneous
│ ├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
├─┬ [email protected] extraneous
│ ├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
├─┬ [email protected]
└─┬ [email protected] extraneous
  ├─┬ [email protected]
  ├─┬ [email protected]

Was looking to see if I could patch it, but may be in the terminal-notifier binary. Let me know, will help find the fix.

Should use gulp-util templating

This plugin would fit better with gulp guidelines if it did things with the file contents.

I think this could be achieved by allowing title and message to be passed through gulp-util template and passing the vinyl object as the data.

See an example in gulp-exec

Could not send message

gulp-notify is throwing an internal error when passing certain error messages on OSX.

Error message from gulp:

Could not send message: Command failed: /bin/sh: -c: line 2: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 7: syntax error: unexpected end of file

gulp task

gulp.task('styles', function () {
  return gulp.src(path.styles.src)
  .pipe($.plumber({errorHandler: $.notify.onError('<%= error.message %>')}))
  .pipe($.rubySass({
    style: 'expanded',
    precision: 10,
    sourcemap: true
  }))
  .pipe($.plumber.stop())
  .pipe($.autoprefixer('last 1 version'))
  .pipe(gulp.dest(path.styles.dist))
  .pipe($.size());
});

i am using the version 1.2.5

Linux port

Could you also support linux distros? (like for example the Gnome notification system).

Notification is triggered more times than it should

With a basic gulpfile, I get 5 times the same notification.
Here is my console output:

[21:23:08] Using gulpfile ~/Projets/TestsGulp/gulpfile.js
[21:23:08] Starting 'iconfont'...
[21:23:08] Finished 'iconfont' after 13 ms
[21:23:08] gulp-svgicons2svgfont: Font created!
[21:23:08] gulp-notify: [Gulp notification] Task iconfont completed.
[21:23:09] gulp-notify: [Gulp notification] Task iconfont completed.
[21:23:09] gulp-notify: [Gulp notification] Task iconfont completed.
[21:23:09] gulp-notify: [Gulp notification] Task iconfont completed.
[21:23:09] gulp-notify: [Gulp notification] Task iconfont completed.

And the associated gulpfile.js:

var gulp = require('gulp');
var notify = require('gulp-notify');
var iconfont = require('gulp-iconfont');
var iconfontcss = require('gulp-iconfont-css');

gulp.task('default', function() {
  gulp.src('./src/*')
    .pipe(notify());
});

gulp.task('iconfont', function() {
  gulp.src(['assets/icons/*.svg'])
    .pipe(iconfontcss({
      fontName: 'icons',
      targetPath: '../css/icons.css',
      fontPath: 'assets/fonts/'
    }))
    .pipe(iconfont({
      fontName: 'icons'
    }))
    .pipe(gulp.dest('assets/fonts/'))
    .pipe(notify('Task iconfont completed.'));
});

Is there anything I'm doing wrong?

1.0.0-beta unpublished?

The https://www.npmjs.org/package/gulp-notify website still shows the latest release as 0.6.2 and 1.0.0-beta has been out for over 2 hours! ;-)

I haven't written any of my own node module yet, so I don't have any experience publishing them. Do you still need to run npm publish on the latest release? or is there a time lag on npmjs.org?

Thanks for a great module!

Error runnning on Windows 8

gulp-notify: [Error running notifier] Could not send message: Command failed:
Exception non g�r�e�: System.Exception: Exception de HRESULT : 0xC00CE508
� Windows.UI.Notifications.ToastNotifier.Show(ToastNotification notification)
� toast.Program.ShowToast(String title, String message, String imageURI, Boolean sound)
� toast.Program.Main(String[] args)

notify and notify.onError not using my title and message

Is it possible to notify with one message if there is an error and another message if there is no error? This works for the success message but the on error part is not using my message.

This ignores my title and message.

.on('error', notify({
                     title: "Bad Doge!",
                     message: "Very Fail!",
                     notifier: growlNotifier
        }))
.pipe(notify({
                title: "Very Unit",
                message: "Such notify. So growl. Many Wow",
                notifier: growlNotifier
        }));

It just sends the error from gulp

Error running gulp

Command failed:

Also tried using notify.onError as in the examples and tried returning a function

.on('error', notify(function(error) {
            return "Such Fail" + error;
        }))

Or is it a issue with gulp-notify-growl?

Oh and also tried this with same result

.pipe(through.obj(function() {
            this.emit('error', 'Something went wrong')
        })
        .on('error', notify.onError())

Really I'm just trying everything because I don't understand it

Cannot switch to old mode now.

Hi, I'm running node version 0.11.11 on a Mac and I'm getting this:

/node_modules/gulp-notify/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:733
    throw new Error('Cannot switch to old mode now.');
          ^
Error: Cannot switch to old mode now.

Also tried with an older version but always the same error.

This probably should be posted on the through2 repo...not sure.

Tests fail but gulp-notify doesn't catch 'error'

I'm running into an issue when running gulp test for a function. Should be pretty simple, using gulp-codeception and gulp-notify. The issue is that when I run the command, codeception generates an error, but notify isn't triggered.

Come to think of it, this may be a gulp-codeception issue, but based on their docs, it should be passing through the 'error' to notify.onError(), so it seems it's not being caught properly in gulp-notify at first glance.

Ref: Pastebin 'test' task code: http://pastebin.com/MP4Rw76q

And then here's the actual results of the command being run...

vagrant@homestead:~/eg.dev$ gulp test
[23:26:11] Using gulpfile ~/eg.dev/Gulpfile.js
[23:26:11] Starting 'test'...
[23:26:11] Finished 'test' after 16 ms
[23:26:14] Codeception PHP Testing Framework v2.0.4
Powered by PHPUnit 4.2.2 by Sebastian Bergmann.

Functional Tests (1) --------------------------------------------------------------------------------
Trying to register as a new user (RegisterCept)                                                 Error
-----------------------------------------------------------------------------------------------------


Time: 2.51 seconds, Memory: 17.50Mb

There was 1 error:

---------
1) Failed to register as a new user in RegisterCept (/home/vagrant/eg.dev/tests/functional/RegisterCept.php)
Couldn't click "Next":
RuntimeException: Call to undefined method FunctionalTester::seeCurrentUrlEqual

Scenario Steps:
24. I click "Next"
23. I fill field {"name":"password_confirm"},"secret"
22. I fill field {"name":"password"},"secret"
21. I fill field {"name":"phone_2"},"555-555-2222"
20. I fill field {"name":"phone_1"},"555-555-1111"
19. I fill field {"name":"email"},"[email protected]"
18. I fill field {"name":"company"},"Testing, Inc."

#1  /home/vagrant/eg.dev/tests/functional/RegisterCept.php:39
#2  /home/vagrant/eg.dev/tests/functional/RegisterCept.php:39

FAILURES!                           
Tests: 1, Assertions: 11, Errors: 1.
[23:26:14] gulp-notify: [Testing Passed] All tests have passed!

Gulp notify Fails on Windows 7 with Growl.

For some reason on the latest version I only get a gulp-notify error.

gulp-notify: [Error in notifier] Error in plugin 'gulp-notify' Command failed:

There is nothing beyond that error. And instead of using Growl it shows a small windows native bubble.

I would prefer using growl for this. Any help would be greatly appreciated. :)

Incorrect OS. node-notify require Mac 10.8 or higher

Hi, I just update to Yosemite and now im getting this error "Error: Incorrect OS. node-notify requires Mac OS 10.8 pr higher."
I saw you update node-notifier to support Yosemite but still is not working.

Someone could help me?

Thanks!

If error connect econnrefused, do not log error

Remove error logging if the error is "econnrefused". This will cause the plugin to still be useful (logging to the console) even when no Growl is found (and implicitly Notification Center and Notify-osd as well).

invalid option: -onLast

After migrating from version 0.6 to version 1.2, every time i use the "onLast" option, i got this error :

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Command failed: /usr/lib/ruby/1.8/optparse.rb:1450:in `complete': invalid option: -onLast (OptionParser::InvalidOption)
    from /usr/lib/ruby/1.8/optparse.rb:1448:in `catch'
    from /usr/lib/ruby/1.8/optparse.rb:1448:in `complete'
    from /usr/lib/ruby/1.8/optparse.rb:1287:in `parse_in_order'
    from /usr/lib/ruby/1.8/optparse.rb:1254:in `catch'
    from /usr/lib/ruby/1.8/optparse.rb:1254:in `parse_in_order'
    from /usr/lib/ruby/1.8/optparse.rb:1248:in `order!'
    from /usr/lib/ruby/1.8/optparse.rb:1339:in `permute!'
    from /usr/lib/ruby/1.8/optparse.rb:1360:in `parse!'
    from /usr/bin/notify-send:14

    at ChildProcess.exithandler (child_process.js:637:15)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Socket.<anonymous> (child_process.js:956:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:465:12)

I'm not really a nodejs expert, any idea ?

Ubuntu notify error

Cannot figure out the problem ((, here is my gulpfile example:

var gulp = require('gulp'),
    util = require('gulp-util'),
    less = require('gulp-less'),
    cssmin = require('gulp-minify-css'),
    jshint = require('gulp-jshint'),
    uglify = require('gulp-uglify'),
    imagemin = require('gulp-imagemin'),
    clean = require('gulp-clean'),
    notify = require('gulp-notify'),
    livereload = require('gulp-livereload');

// Styles
gulp.task('styles', function(){
    gulp.src('src/less/*.less')
    .pipe(less())
    .pipe(cssmin())
    .pipe(gulp.dest('build/css'))
    .pipe(notify('Styles task completed'));
});

gulp.task('default', function() {
    gulp.start('styles');
});

gulp.task('watch', function(){
    server = livereload();
    gulp.watch('src/less/**/*.less', function(e){
        gulp.start('styles');
        server.changed(e.path);
    });
});

When i change the file under less directory everything seems to be ok, i see the 'Styles task completed' gulp notification, but on second change i get the console error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: notify-send must be installed on the system.
    at Notifier.notify (/home/andrey/Projects/mixacode/app/assets/node_modules/gulp-notify/node_modules/node-notifier/lib/notify-send.js:67:14)
    at report (/home/andrey/Projects/mixacode/app/assets/node_modules/gulp-notify/index.js:85:5)
    at Transform.notify [as _transform] (/home/andrey/Projects/mixacode/app/assets/node_modules/gulp-notify/index.js:19:5)
    at Transform._read (/home/andrey/Projects/mixacode/app/assets/node_modules/gulp-notify/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:179:10)
    at Transform._write (/home/andrey/Projects/mixacode/app/assets/node_modules/gulp-notify/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:167:12)
    at doWrite (/home/andrey/Projects/mixacode/app/assets/node_modules/gulp-notify/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:223:10)
    at writeOrBuffer (/home/andrey/Projects/mixacode/app/assets/node_modules/gulp-notify/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:213:5)
    at Transform.Writable.write (/home/andrey/Projects/mixacode/app/assets/node_modules/gulp-notify/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:180:11)
    at Stream.ondata (stream.js:51:26)
    at Stream.EventEmitter.emit (events.js:95:17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.