Coder Social home page Coder Social logo

gulp-plumber's Introduction

πŸ’ gulp-plumber

NPM version Build Status Dependency Status

Prevent pipe breaking caused by errors from gulp plugins

This πŸ’-patch plugin is fixing issue with Node Streams piping. For explanations, read this small article.

Briefly it replaces pipe method and removes standard onerror handler on error event, which unpipes streams on error by default.

Usage πŸ’

First, install gulp-plumber as a development dependency:

npm install --save-dev gulp-plumber

Then, add it to your gulpfile.js:

var plumber = require('gulp-plumber');
var coffee = require('gulp-coffee');

gulp.src('./src/*.ext')
	.pipe(plumber())
	.pipe(coffee())
	.pipe(gulp.dest('./dist'));

API πŸ’

πŸ’ plumber([options])

Returns Stream, that fixes pipe methods on Streams that are next in pipeline.

options

Type: Object / Function Default: {}

Sets options described below from its properties. If type is Function it will be set as errorHandler.

options.inherit

Type: Boolean Default: true

Monkeypatch pipe functions in underlying streams in pipeline.

options.errorHandler

Type: Boolean / Function
Default: true

Handle errors in underlying streams and output them to console.

  • function - it will be attached to stream on('error').
  • false - error handler will not be attached.
  • true - default error handler will be attached.

plumber.stop()

This method will return default behaviour for pipeline after it was piped.

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

gulp.src('./src/*.scss')
    .pipe(plumber())
    .pipe(sass())
    .pipe(uglify())
    .pipe(plumber.stop())
    .pipe(gulp.dest('./dist'));

License πŸ’

MIT License

gulp-plumber's People

Contributors

caleyd avatar callumlocke avatar demurgos avatar dgreif avatar floatdrop avatar kmoe avatar lukehorvat avatar pgilad avatar plwalters avatar sahat avatar shinnn avatar simnalamburt 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

gulp-plumber's Issues

Does not handle gulp.src errors?

Running this code simply results in a standard gulp error...

gulp.src('./config1.json')
    .pipe($.plumber(function() {
      console.log('There was an issue');
      this.emit('end');
    }));

... Error: File not found with singular glob

Not sure if I'm using correctly, but I had figured that plumber would pick this up as well.

npm ERR! Failed to parse json. npm ERR! package.json must be actual JSON, not just JavaScript.

npm http 304 https://registry.npmjs.org/gulp-plumber
npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: /Users/khmelevskii/.npm/gulp-plumber/0.6.3/package/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

NPM : Tell the package author to fix their package.json file.

When I try the install gulp-plumber this errors shown by npm

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files (x86)\nodejs\node.exe',
1 verbose cli 'C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '--save-dev',
1 verbose cli 'gulp-plumber' ]
2 info using [email protected]
3 info using [email protected]
4 verbose stack Error: Failed to parse json
4 verbose stack Trailing comma in object at 37:3
4 verbose stack }
4 verbose stack ^
4 verbose stack at parseError (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:406:25)
4 verbose stack at parseJson (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:86:51)
4 verbose stack at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:60:33
4 verbose stack at FSReqWrap.readFileAfterClose as oncomplete
5 verbose cwd C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\external\Green-Time\dev
6 error Windows_NT 10.0.10240
7 error argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install" "--save-dev" "gulp-plumber"
8 error node v4.2.2
9 error npm v2.7.4
10 error file C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\external\Green-Time\dev\package.json
11 error code EJSONPARSE
12 error Failed to parse json
12 error Trailing comma in object at 37:3
12 error }
12 error ^
13 error File: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\external\Green-Time\dev\package.json
14 error Failed to parse package.json data.
14 error package.json must be actual JSON, not just JavaScript.
14 error
14 error This is not a bug in npm.
14 error Tell the package author to fix their package.json file. JSON.parse
15 verbose exit [ 1, true ]

Compatibility with gulp-if?

It looks like using gulp-if is breaking gulp-plumber error catching:

  function lessChannel() {
    return require('stream-combiner')(
      gulpif('**/*.less', less()),
      // less(), // is properly handled by upstream plumber
      autoprefixer('last 1 version'),
      gulp.dest(src.tmp)
    );
  };
  gulp.task('src/styles', function() {
    gulp.src(src.styles, {cwd: src.cwd, base: src.cwd})
      .pipe(plumber())
      .pipe(lessChannel());
  });

Related gulp-if issue:
robrich/gulp-if#40

Issue with gulp-stylus

Hi there, so I have pipe(plumber()) working great with .coffee files, but for some reason with my stylus task, it seems it isn't working. When I hit a compilation error, I have to spin up gulp again and all other tasks stop.

Here is my task:

var gulp = require("gulp"),
  notify = require("gulp-notify"),
  plumber = require('gulp-plumber'),
  stylus = require('gulp-stylus');

  gulp.task("stylus", function() {
    return gulp.src("public/stylesheets/application.styl")
      .pipe(plumber())
      .pipe(stylus({
        set: [
          "resolve url",
          "include css",
          "linenos",
          "compress"
        ]
      })).on("error", notify.onError({
        message: "<%= error.message %>",
        title: "Stylus Error"
      }))
      .pipe(gulp.dest("public/stylesheets"));
  });

Is this a known issue with plumber? I tried without the .on("error") method and it still fails.

error with gulp-autoprefixer 2.0.0

gulp-autoprefixer 1.0.1 is ok, but gulp-autoprefixer 2.0.0 get error

gulp.task('sass', function(){
   return gulp.src('app/assets/styles/b.scss')
    .pipe($.plumber())
    .pipe($.rubySass({
      style: 'expanded',
      precision: 10
    }))
    .pipe($.autoprefixer({browsers: ['last 1 version']}))
    .pipe(gulp.dest('.tmp/styles'));
});

error

Plumber found unhandled error:
 CssSyntaxError in plugin 'gulp-autoprefixer'
Message:
    /Users/oych/evolution/b.css.map:3:1: Unknown word
Details:
    reason: Unknown word
    file: /Users/oych/evolution/b.css.map
    line: 3
    column: 1
    source: {
"version": 3,
"mappings": "",
"sources": [],
"names": [],
"file": "b.css"
}
    fileName: /var/folders/cv/tzl5b7s559j104k1llztqrcr0000gn/T/gulp-ruby-sass/_14139e58-9ebe-4c0f-beca-73a65bb01ce9/b.css.map

Stopping dependent task, but not gulp

I have the two following tasks:

gulp.task('js-quality', function () {
  return gulp.src('./src/js/**/*.js')
    .pipe(plugins.plumber({ errorHandler: onError }))
    .pipe(plugins.jscs())
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter(stylish));
});

gulp.task('js', ['js-quality'], function () {
  var bundler = browserify('./src/js/test.js');

  return bundler.bundle()
    .on('error', console.log.bind(console, 'Browserify Error'))
    .pipe(source('bundle.js'))
    .pipe(gulp.dest('./demo/build'));
});

When js-quality fails, I want onError to be called (which pipes the error through to browser-sync and beeps), but I don't want the js task to run.

Is there any way to do this, or is this something I'll have to work around until Gulp 4?

Fails on return

Hey there!

AWESOME πŸ’ patch, love it so much!

I noticed if I return the stream in a task, 'watch' freezes after a stream error:

gulp.task('styles', function() {
    return gulp.src('application/static/style/*.scss')
        .pipe(plumber())
        .pipe(sass())
        .pipe(gulp.dest('public/static/style/'));
});

If I remove 'return' it doesn't freeze, when an error occurs:

gulp.task('styles', function() {
    gulp.src('application/static/style/*.scss')
        .pipe(plumber())
        .pipe(sass())
        .pipe(gulp.dest('public/static/style/'));
});

Returning the stream is mentioned in the gulp docs here:
https://github.com/gulpjs/gulp/blob/master/docs/API.md#async-task-support

Thanks! :)

Add debug functionality

If gulpfile.js executed with DEBUG=plumber - trace all vinyl objects path's. It will take some time to make it look good.

Not working with gulp-less

I used plumber to prevent exiting on any error thrown while compiling my less files.I purposely made an error in my less file and of course an error occurred while compiling it.I expected that plumber can prevent it but it actually didn't work at all. Or Is there anything wrong in my gulpfile ?
Here's following the critical code of my gulpfile.js and i run "gulp watch" to watch my less files and auto-compiling on modifications.

/* gulpfile.js */
var changedFile;
gulp.task("single-less", function() {
    return gulp.src(changedFile)
            .pipe(plumber())
            .pipe(less())
            .pipe(gulp.dest(config.cssdist))
            .pipe(livereload());
});
var lessWatcher;
gulp.task("watch", function() {
    livereload.listen();
    lessWatcher = gulp.watch(config.less(), ["single-less"]);
    lessWatcher.on("change", function(file) {
        if (file.type === "changed") {
            changedFile = file.path;
            gulp.start("single-less");
        }
    });
});

error No valid versions available for gulp-plumber

I am getting this error while installing gulp-plumber (tried to clear cache):

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install',
1 verbose cli   '--save-dev',
1 verbose cli   '--force',
1 verbose cli   'gulp-plumber' ]
2 info using [email protected]
3 info using [email protected]
4 warn using --force I sure hope you know what you are doing.
5 verbose npm-session b1ebc80a75106bac
6 silly install loadCurrentTree
7 silly install readLocalPackageData
8 http fetch GET 200 https://registry.npmjs.org/gulp-plumber 415ms
9 silly fetchPackageMetaData error for gulp-plumber@latest No valid versions available for gulp-plumber
10 verbose type tag
11 verbose stack gulp-plumber: No valid versions available for gulp-plumber
11 verbose stack     at pickManifest (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/npm-pick-manifest/index.js:19:11)
11 verbose stack     at fetchPackument.then.packument (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/manifest.js:39:14)
11 verbose stack     at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
11 verbose stack     at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
11 verbose stack     at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
11 verbose stack     at Promise._settlePromise0 (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
11 verbose stack     at Promise._settlePromises (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
11 verbose stack     at Async._drainQueue (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
11 verbose stack     at Async._drainQueues (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
11 verbose stack     at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
11 verbose stack     at runCallback (timers.js:773:18)
11 verbose stack     at tryOnImmediate (timers.js:734:5)
11 verbose stack     at processImmediate [as _immediateCallback] (timers.js:711:5)
12 verbose cwd xxxxxxxxxx
13 verbose Linux 4.14.11-mainline-rev1
14 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save-dev" "--force" "gulp-plumber"
15 verbose node v9.3.0
16 verbose npm  v5.5.1
17 error code ENOVERSIONS
18 error No valid versions available for gulp-plumber
19 verbose exit [ 1, true ]

Plumber failing to continue after async error

Hello!

I wrote three simplified scenarios to try to understand why plumber is failing to keep the stream flow after some error ocurred on my plugin (which transforms vinyl files asynchronously).

I'm using node v0.12.2 and I'm running my tests with node gulp.js

This is the first case:
https://gist.github.com/rimassa/229af1fe328bff31e817
It's a simple pipeline, which retrieves files from a instance of FileSource, passes them through a plugin (which just re-emitts the same files after 100 milliseconds and stores them in a instance of FileDest.
Plumber is connected right after the FileSource. My plugins does not emit any errors and everything works perfectly, as you can see on "output.log".

This is the second scenario:
https://gist.github.com/rimassa/62ce1f9d2573096d549a
This code is almost identical to the previous one, except for my plugin. It emits an error on the fifth file, by calling cb(new Error(...)). As you may notice on the file 'output.log', plumber is not able to recover the stream flow: the processing stops at the fifth file.

I was able to make this work in the third case:
https://gist.github.com/rimassa/dfa57285d3898c9fe0c6
I've just replaced cb(new Error(...)) with this.emit('error', new Error(...)); cb(). Now plumber seems to handle the error and resume the stream, processing the next five files.

Why does it happens? Is it ok to use the workaround I did on the last scenario?

Cheers
Ricardo

0.6.6 Broken

I think it doesn't let the gulp task finish anymore.

[17:51:13] Plumber found unhandled error:
 Error in plugin 'gulp-less'
Message:
    Unrecognised input in file g:\www\luto\app\styles\main.less line no. 7
Details:
    type: Parse
    filename: g:\www\luto\app\styles\main.less
    index: 67
    line: 7
    callLine: NaN
    callExtract: undefined
    column: 0
    extract: ,,
    lineNumber: 7
    fileName: g:\www\luto\app\styles\main.less

Compared to:

[18:03:23] Plumber found unhandled error: Error in plugin 'gulp-less'
Message:
    missing closing `}` in file g:\www\luto\app\styles\main.less line no. 5
Details:
    type: Parse
    filename: g:\www\luto\app\styles\main.less
    index: 66
    line: 5
    callLine: NaN
    callExtract: undefined
    column: 5
    extract: ,body {,  background: red;
    lineNumber: 5
    fileName: g:\www\luto\app\styles\main.less
[18:03:23] Finished 'dev-styles' after 27 ms

0.6.5 works.

Gulp-rigger doesnt work with gulp-plumber

Gulp-rigger doesnt work with gulp-plumber. Buffer.js:67 error appears.

var gulp = require('gulp'),
    plumber = require('gulp-plumber'),
    rigger = require('gulp-rigger');

var onError = function(err) {
        notify.onError({message: "Failed\n<%= error.message %>", sound: true})(err);
        this.emit('end');
}
gulp.task('javascript', function() {
    gulp.src('src/js/*.js')
        .pipe(plumber({errorHandler: onError}))
        .pipe(rigger())
        .pipe(gulp.dest('./js'))
        .pipe(onComplete());
});
gulp.task('default', ['javascript']);

Stops after "Error in plugin 'gulp-postcss' "

Gulp task:

gulp.task('css', function () {
    var processors = [
        cssnested,
        cssimport,
        csssimplevars,
        cssnext(),
        cssnano
    ];
    return gulp.src('./src/css/main.css')
        .pipe(plumber())
        .pipe(sourcemaps.init())
            .pipe(postcss(processors))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('./css'))
        .pipe(reload({stream:true}));
});

gulp.task('watch', function() {
    gulp.watch(paths.css, ['css']);
});

Whenever there is an error, like importing file that does not exist (wrong path), I get this error which stops gulp:

[15:31:29] Starting 'css'...
[15:31:29] Plumber found unhandled error:
 Error in plugin 'gulp-postcss'
Message:
    /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme/src/css/main.css:5:1: Failed to find 'base/header' from /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme
    in [
        /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme/src/css
    ]
Details:
    originalMessage: Failed to find 'base/header' from /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme
    in [
        /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme/src/css
    ]
    fileName: /Users/Nerijus/Sites/Personal/solofront/user/themes/solofront-theme/src/css/main.css
    lineNumber: 5
    columnNumber: 1

Really annoying causing me to restart my tasks every time css error is made. Am I doing something wrong?

Expose error handler

It would be great if we could use the same error handler when some plugins require explicitly handling errors (e.g. browserify).

gulp.task('example', function () {
    return browserify({ debug: true })
        .bundle()
        .on('error', plumber.handleError)
        .pipe(plumber())
        .pipe(source('example.js'))
        .pipe(buffer())
        .pipe(gulp.dest('dist/js'))
})

Fails after upgrading to latest version of nodejs (v4.2.1)

I was using gulp-plumber for months on NodeJS version of 0.10.40. And upon upgrading to latest version of NodeJs 4.2.1, it no longer works. When I am running a task with gulp-watch and a file is updated, it crashes with:

C:\dev\website\node_modules\gulp-ng-annotate\index.js:48
    if (file.isNull()) {
             ^

TypeError: file.isNull is not a function
    at Transform._transform (C:\dev\website\node_modules\gulp-ng-annotate\index.js:48:14)
    at Transform._read (C:\dev\website\node_modules\gulp-ng-annotate\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:184:10)
    at Transform._write (C:\dev\website\node_modules\gulp-ng-annotate\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:172:12)
    at doWrite (C:\dev\website\node_modules\gulp-ng-annotate\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:237:10)
    at writeOrBuffer (C:\dev\website\node_modules\gulp-ng-annotate\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:227:5)
    at Transform.Writable.write (C:\dev\website\node_modules\gulp-ng-annotate\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:194:11)
    at write (C:\dev\website\node_modules\gulp-plumber\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:623:24)
    at flow (C:\dev\website\node_modules\gulp-plumber\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:632:7)
    at C:\dev\website\node_modules\gulp-plumber\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:600:7
    at doNTCallback0 (node.js:417:9)

Edit: works when I rollback gulp-watch to 1.2.1.

How to make it works with BrowserSync?

Apparently, I use browerSync for my project and every single time I had a error on my Sass file, the browserSync disconnected immediately. And it still happens whether I use gulp-plumber or not. Please help me with this one!

Breaks asynchronous down-stream streams

This simple code creates an asynchronous transform (that doesn't do anything other than wait a bit). It sets up a simple gulp config where you pipe through plumber and then to that asynchronous transform.

I think that it has something to do with gulp-plumber, but the transform never emits any data for anything downstream.

npm install gulp through gulp-plumber
// index.js
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var through = require('through');

var transform = through(function(file) {
  this.pause();
  setTimeout(function() {
    this.queue(file);
    this.resume();
  }.bind(this), 100);
});

gulp.src('index.js')
  .pipe(plumber())
  // .pipe(through())
  .pipe(transform)
  .pipe(gulp.dest('out'));

The commented line in here is a workaround. If you simply create a synchronous stream following plumber, then everything works as expected. Plumber also seems to still notice errors properly in the asynchronous setup if you add this.emit('error', new Error('an example error')) regardless of whether or not that commented line is included.

Freezes after first call in Gulp v4 watch

I'm lead to believe the following works in earlier versions of Gulp. However, in Gulp v4 using the built-in gulp.watch method, this successfully swallows errors the first time a change is detected but prevents future changes being detected.

function errorHandler(err) {
  gutil.beep()
  this.emit('end')
}

// gulp.src( ... )
  .pipe(plumber({ errorHandler }))
  // .pipe( ... )

Is this project intended to support Gulp v4?
Using Node v7.1.0.

Using plumber in a sub section of the pipeline

gulp.src()
  .pipe(plumber())
  .pipe(myPlugin)
  .pipe(plumber.stop())
  .pipe(anotherPlugin())
  .pipe(gulp.dest())

Gulp plumber would not patch the pipe method of a plugin by simply testing if it's contructor match plumber.stop.

How to beep on error but keep error message informative

There a lot of instructions on the web regarding how to extend errorHandler method to beep and show notification on error, but all those methods breaks the basic idea of plumber: tiny and informative error message.

Take a look to difference between default error message
great_error_msg

and error message that usually comes with extended errorHandler method
poor_error_msg

One of extended errorHandler implementation

var onError = function(err) {
    notify.onError({
        title:    "Error!",
        message:  "<%= error.message %>",
        sound:    "Beep"
    })(err);
    this.emit('end');
};

gulp.task('scripts', function() {
    return gulp.src(src + '/js/**/*.js')
    .pipe(plumber({ errorHandler: onError }))
    ...

Default error message shows the most important information, like path to file, line, error message, even sample of code from that line.
While extended message is much worse, it shows only error message without additional information.

On the other hand it's not convenient to code without notification in case of error. In my case console is almost always hidden so I can not notice if it crashes.

As I said, there are many attempts on the web to solve this problem, but they all are not good enough.

I would be very grateful to you if you've added the ability to beep and display notification on error by default. Or at least show us how to extend the errorHandler method to make it display error messages in console such informative and beautifully as it is by defalt

Changes stream behavior

Observe this:

var vfs = require('vinyl-fs');
var plumber = require('gulp-plumber');

var stream = vfs.src(__filename)
  .pipe(plumber())
  .pipe(vfs.dest('/tmp'))
  .on('data', function() {
    console.log("Never happens")
  });

The on('data') on the last stream never happens. But it should.

Not working with gulp-jsdoc

I have a syntax error in a file (missing '};') and the gulp-jsdoc module will throw an exception, but gulp-plumber does not catch this and keep working.

Sample JS:
angular.module('MyApp').service("Data", ["$firebaseObject", "$firebaseArray", "GetFireBaseObject",
function($firebaseObject, $firebaseArray, GetFireBaseObject) {
var MemberRef = GetFireBaseObject.DataURL('data/');

    this.AddMember = function(MemberKey) {
        var OneMemberRef = MemberRef.child(MemberKey);
        return $firebaseObject(OneMemberRef);
    };

    this.DeleteMember = function(MemberKey) {
        var OneMemberRef = MemberRef.child(MemberKey);
        OneMemberRef.remove();

// }; // Commented out to cause error.

}

]);

Gulp fails with Error: Line xx: Unexpected token )

Gulp.Task:
gulp.task('Documentation-API', function() {
return gulp.src(SourcePath.javascript, {cwd: RootDir.home})
.pipe(plumber( { errorHandler: OnErrorHandler } ))
.pipe(jsdoc.parser())
.pipe(jsdoc.generator(RootDir.docs + DocumentationPath.javascript )
);
});

adding data listener breaks plumber

Attaching a data listener (e.g .on('data', function(){})) to plumbler() breaks it whenever a stream emits an error.

Example:

gulp.src('./**/*.coffee')
  .pipe(watch()) // works fine
  .pipe(plumber())
    // this breaks plumber when coffee() emits error
    .on('data', function(){}) 
  .pipe(coffee({bare: true})
  // ....

Adding another .pipe(plumber()) after the .on('data') "fixes" it.

Stack trace:

...
[gulp] Compiled 'coffee/subdir/a.coffee' to 'src/subdir/a.js'

Error: /Users/albertoleal/Documents/Projects/javascript/coffeescript-seed-project/coffee/subdir/b.coffee:1:6: error: unexpected IDENTIFIER
b = 2sadsad
     ^^^^^^
    at module.exports (/Users/albertoleal/Documents/Projects/javascript/coffeescript-seed-project/node_modules/gulp-coffee/lib/formatError.js:5:10)
    at Stream.modifyFile (/Users/albertoleal/Documents/Projects/javascript/coffeescript-seed-project/node_modules/gulp-coffee/index.js:27:22)
    at Stream.stream.write (/Users/albertoleal/Documents/Projects/javascript/coffeescript-seed-project/node_modules/gulp-coffee/node_modules/event-stream/node_modules/through/index.js:26:11)
    at PassThrough.ondata (stream.js:51:26)
    at PassThrough.EventEmitter.emit (events.js:117:20)
    at PassThrough.<anonymous> (_stream_readable.js:746:14)
    at PassThrough.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at PassThrough.Readable.push (_stream_readable.js:127:10)
    at PassThrough.Transform.push (_stream_transform.js:140:32)
    at afterTransform (_stream_transform.js:96:12)
    at TransformState.afterTransform (_stream_transform.js:74:12)
    at PassThrough._transform (_stream_passthrough.js:40:3)
    at PassThrough.Transform._read (_stream_transform.js:179:10)
    at PassThrough.Transform._write (_stream_transform.js:167:12)
    at doWrite (_stream_writable.js:221:10)
    at writeOrBuffer (_stream_writable.js:211:5)
    at PassThrough.Writable.write (_stream_writable.js:180:11)
    at PassThrough.ondata (stream.js:51:26)
    at PassThrough.EventEmitter.emit (events.js:117:20)
    at PassThrough.<anonymous> (_stream_readable.js:746:14)
    at PassThrough.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at PassThrough.Readable.push (_stream_readable.js:127:10)
    at PassThrough.Transform.push (_stream_transform.js:140:32)
    at afterTransform (_stream_transform.js:96:12)
    at TransformState.afterTransform (_stream_transform.js:74:12)
    at PassThrough._transform (_stream_passthrough.js:40:3)
    at PassThrough.Transform._read (_stream_transform.js:179:10)
    at PassThrough.Transform._write (_stream_transform.js:167:12)
    at doWrite (_stream_writable.js:221:10)
    at writeOrBuffer (_stream_writable.js:211:5)
    at PassThrough.Writable.write (_stream_writable.js:180:11)
    at write (_stream_readable.js:583:24)
    at flow (_stream_readable.js:592:7)
    at Duplex.pipeOnReadable (_stream_readable.js:624:5)
    at Duplex.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at Duplex.Readable.push (_stream_readable.js:127:10)
    at Duplex._write (/Users/albertoleal/Documents/Projects/javascript/coffeescript-seed-project/node_modules/gulp-watch/index.js:39:50)
    at doWrite (_stream_writable.js:221:10)
    at clearBuffer (_stream_writable.js:299:5)
    at onwrite (_stream_writable.js:257:7)
    at WritableState.onwrite (_stream_writable.js:97:5)
    at null._onTimeout (/Users/albertoleal/Documents/Projects/javascript/coffeescript-seed-project/node_modules/gulp-watch/node_modules/gaze/lib/gaze.js:405:24)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Package unpublished from npm again?

Not able to install gulp-plumber with npm (or yarn). I know that it was unavailable 4 days ago during the npm incident, but I'm getting the same errors today. Has the package been unpublished again?

npm 3.10.10

$ npm info gulp-plumber

npm ERR! code E404

npm ERR! 404 Unpublished by npm on 2018-01-06T18:36:22.265Z
npm ERR! 404 
npm ERR! 404  'gulp-plumber' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

$ npm i gulp-plumber

npm ERR! Cannot convert undefined or null to object
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm 5.6.0

$ npm i gulp-plumber

npm ERR! code ENOVERSIONS
npm ERR! No valid versions available for gulp-plumber

Provide a convenience function that would patch the gulp.src

import plumber from 'gulp-plumber';

export default (gulp, plumberOptions = {}) => {
    let gulpSrc;

    gulpSrc = gulp.src;

    return (...args) => {
        return gulpSrc
            .apply(gulp, args)
            .pipe(plumber(plumberOptions))
    };
};

Then user can simply do:

import gulp from 'gulp';
import {
    patchGulpSrc
} from 'gulp-plumber';

gulp.src = patchSrc(gulp);

compatibility with lazypipe

It works well!

gulp.task('less', function() {
  return gulp.src('css/*.less', { cwd: 'app/**' })
  .pipe($.plumber())
  .pipe($.less())
  .pipe(gulp.dest('.tmp'));
});
[gulp] Starting 'less'...
[gulp] Plumber found unhandled error: [gulp] Error in plugin 'gulp-less': .make-
grid-columns is undefined in file bower_components\bootstrap\less\
grid.less line no. 48
[gulp] Finished 'less' after 314 ms

But with lazy pipe:

var less = lazypipe()
  .pipe($.less)
  .pipe(gulp.dest, '.tmp');

gulp.task('less', function() {
  return gulp.src('css/*.less', { cwd: 'app/**' })
  .pipe($.plumber())
  .pipe(less());
});
[gulp] Starting 'less'...
[gulp] 'less' errored after 317 ms .make-grid-columns is undefined in file bower_components\bootstrap\less\grid.less line no. 48

I also tried putting plumber inside the lazy pipe:

var less = lazypipe()
  .pipe($.plumber)
  .pipe($.less)
  .pipe(gulp.dest, '.tmp');

gulp.task('less', function() {
  return gulp.src('css/*.less', { cwd: 'app/**' })
  .pipe(less());
});
[gulp] Starting 'less'...
[gulp] 'less' errored after 317 ms .make-grid-columns is undefined in file bower_components\bootstrap\less\grid.less line no. 48

Converting null

Hello,

When trying to install gulp-plumber with nom install --save gulp-plumber I get the following message from NPM: Cannot convert undefined or null to object . It seems there is somewhere a nasty bug?

My terminal output:

$ npm install
npm WARN deprecated [email protected]: ...psst! Your project can stop working at any moment because its dependencies can change. Prevent this by migrating to Yarn: https://bower.io/blog/2017/how-to-migrate-away-from-bower/
npm WARN deprecated [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm ERR! Darwin 17.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.11.3
npm ERR! npm  v3.10.10

npm ERR! Cannot convert undefined or null to object
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/xvilo/projects/customer-invoice-manager/npm-debug.log

Last lines of npm-debug.log:

5689 verbose addNamed ">=4.0.1 <5.0.0" is a valid semver range for object-assign
5690 silly addNameRange { name: 'object-assign',
5690 silly addNameRange   range: '>=4.0.1 <5.0.0',
5690 silly addNameRange   hasData: false }
5691 silly mapToRegistry name object-assign
5692 silly mapToRegistry using default registry
5693 silly mapToRegistry registry https://registry.npmjs.org/
5694 silly mapToRegistry data Result {
5694 silly mapToRegistry   raw: 'object-assign',
5694 silly mapToRegistry   scope: null,
5694 silly mapToRegistry   escapedName: 'object-assign',
5694 silly mapToRegistry   name: 'object-assign',
5694 silly mapToRegistry   rawSpec: '',
5694 silly mapToRegistry   spec: 'latest',
5694 silly mapToRegistry   type: 'tag' }
5695 silly mapToRegistry uri https://registry.npmjs.org/object-assign
5696 verbose addNameRange registry:https://registry.npmjs.org/object-assign not in flight; fetching
5697 verbose stack TypeError: Cannot convert undefined or null to object
5697 verbose stack     at pickVersionFromRegistryDocument (/usr/local/lib/node_modules/npm/lib/fetch-package-metadata.js:125:29)
5697 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/iferr/index.js:13:50
5697 verbose stack     at /usr/local/lib/node_modules/npm/lib/utils/pulse-till-done.js:20:8
5697 verbose stack     at saved (/usr/local/lib/node_modules/npm/lib/cache/caching-client.js:174:7)
5697 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:241:18
5697 verbose stack     at FSReqWrap.oncomplete (fs.js:123:15)
5698 verbose cwd /Users/xvilo/projects/customer-invoice-manager
5699 error Darwin 17.3.0
5700 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
5701 error node v6.11.3
5702 error npm  v3.10.10
5703 error Cannot convert undefined or null to object
5704 error If you need help, you may report this error at:
5704 error     <https://github.com/npm/npm/issues>
5705 verbose exit [ 1, true ]

Weird behaviour for 0.5.3

I cloned this repo and created some file:

var es = require('event-stream');
var plumber = require('./');

var badBoy = es.through(function(data) {
    if(data % 2 == 0)
        return this.emit('error', new Error(data));

    this.emit('data', data);
});

es.readArray([1,2,3,4,5,6])
    .pipe(plumber())
    .pipe(badBoy)
    .pipe(es.through(console.log))

Output:

1
[gulp] Plumber found unhandled error: Error: 4
[gulp] Plumber found unhandled error: Error: 6

If I use [email protected] using same code, I get output:

1
[gulp] Plumber found unhandled error: Error: 2
3
[gulp] Plumber found unhandled error: Error: 4
5
[gulp] Plumber found unhandled error: Error: 6

Don't re-color errors

This line turns all text red in the error message, unless it has already been colored:

gutil.colors.red(trim(error.toString())));

Looks bad for plugins that output detailed messages or ascii, like jscs visually reporting the exact location of an error.

Accept error handler as direct argument

I would like to write code like .pipe(plumber(myErrorHandler)). I'm suggesting to accept an error handler function as primary argument. It could be implemented like this (in beginning of plumber function):

if (typeof opts === 'function') {
  opts = { errorHandler: opts };
}

This wouldn't change any of the other accepted options.

Error: Can't pipe to undefined

Just been looking at capturing Sass compilation errors from gulp-ruby-sass and while the errors are captured and reported, I always get this undefined error. And when the files DO compile successfully, I still get the error and no final notify message:

var gulp = require('gulp'), 
    plumber = require('gulp-plumber'),
    rename = require('gulp-rename'), 
    notify = require('gulp-notify'), 
    sass = require('gulp-ruby-sass'), 
    cssmin = require('gulp-cssmin'),
    header = require('gulp-header'), 
    notifyOptions = {
        title: 'Test',
        sound: 'Frog',
        icon: './ui-theme/images/apple-touch-icon.png',
        onLast: true
    };

/**
 * Sass theme compilation
 */
gulp.task('css', function () {

    var notifyOptions = notifyOptions;

    gulp.src('./scss/styles.scss')
        .pipe(plumber(function (err) { 
            return notify().write(err);
        }))
        .pipe(sass({
            style: 'expanded', 
            lineNumbers: true
        }))
        .pipe(gulp.dest('./assets/css'))
        .pipe(cssmin())
        .pipe(rename({
            suffix: '.min'}
        ))
        .pipe(gulp.dest('./assets/css'))
        .pipe(notifyOptions);

});

The Sass files compile fine, so I'm not sure why this error is being thrown.

gulp-plumber handling syntax errors only in the main sass file and not in partials

I'm having an issue with gulp-plumber, when I intentionally make a syntax error in my main file, the error is being shown in console (so it works perfectly) but when I make an error in some partial sass file it compiles and ignore the error for some reason! Also, it only handles the error if I do an error in partial name in the @import line (i.e. @import 'compLnents/buttons') and not when I write (@iLport 'components/buttons')

this is my gulpfile.js

var gulp = require('gulp');

// Plugins
var plugins = require('gulp-load-plugins')();

var sassPattern = 'sass/**/*.scss';

// Sass to CSS
gulp.task('sass', function() {
	// Gets all .scss files in sass/ and children dirs
	return gulp.src(sassPattern)
		.pipe(plugins.plumber(function(error) {
			console.log(error.toString());
			this.emit('end');
		}))
		.pipe(plugins.sourcemaps.init())
		.pipe(plugins.sass())
		.pipe(plugins.minifyCss())
		.pipe(plugins.sourcemaps.write('.'))
		.pipe(gulp.dest('css'))
});

// Watch task
gulp.task('watch', function() {
	return gulp.watch(sassPattern, ['sass']);
});

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

Plumber busts task out of `gulp.watch`

When using gulp.watch, here’s what happens:

$ gulp watch
[11:36:53] Starting 'scripts'...
[11:36:53] Finished 'scripts' after 197 ms
[11:36:53] Starting 'styles'...
[11:36:53] Plumber found unhandled error:
 Error in plugin 'gulp-less'
Message:
    Unrecognised input. Possibly missing something in ...
Details:
    ...
# Changed some files
[11:37:15] Starting 'scripts'...
[11:37:15] Finished 'scripts' after 179 ms
# Changed some files again
[11:39:10] Starting 'scripts'...
[11:39:10] Finished 'scripts' after 179 ms

After an error has been caught in scripts, the task is never resumed. Is this the intended behavior?

Not working with gulp-sass

My terminal still returns an error and breaks my task when there's an error in my Sass. This is what my task looks like:

gulp.task('sass', function() {
  return gulp.src(['./src/scss/*.scss', './src/scss/**/*.scss'])
    .pipe(plumber())
    .pipe(sass({
      includePaths : [
        './lib/basscss/scss',
        './lib/fluidbox/css'
      ],
      outputStyle: 'expanded'
    }))
    .pipe(prefix({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(minifyCSS())
    .pipe(gulp.dest('./_site/public/css'))
    .pipe(gzip())
    .pipe(gulp.dest('./_site/public/css'))
    .pipe(reload({stream: true}))
});

Any idea why it keeps breaking? Any help is appreciated. Thanks in advance!

Any error handlers named "onerror" get detached

The loop here https://github.com/floatdrop/gulp-plumber/blob/master/index.js#L9 removes every function named onerror that is attached on('error').

The good news is, this gets rid of the default error handler from readable-stream. The bad news is that it removes anything else that gets attached which has the name onerror.

In particular, I ran into an issue running gulp-plumber with stream-combiner. dominictarr/stream-combiner#17 I think it's not the only place that this might trip someone up.

Is there any other way to find the default handler besides just the name onerror? Maybe grabbing it based a combination of the name and index? Just something in place to make sure that only the default onerror gets detached and nothing else.

Plumber show error only 1 file - gulp-sass

Hi, I need a little help, when we change something especially in the main.scss file there will be an error, when we change something in another file there is no error at all, where can the error be?

 gulp.task( "css", function() {
    gulp.src( "assets/scss/main.scss" )
    .pipe( plumber() )
    .pipe( sass.sync({
        outputStyle: 'compressed'
    })
    )
    .pipe( autoprefixer({
        browsers: ["last 8 version", "IE 9"]
    }))
    .pipe(concat('main.min.css'))
    .pipe( gulp.dest( "dist/css/" ))
    .pipe( browserSync.stream() );
});
gulp.task( "watch", function() {
    gulp.watch( "assets/scss/**/*.scss", ["css"] );
});

main.scss

// Global
@import "global";
//Header
@import "header/header";
@import "header/mobile-menu";
//Front-page
@import "front-page/front";
// Footer
@import "footer";

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.