Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Exit code 0 on failed require #479

Closed
popham opened this issue May 20, 2014 · 14 comments
Closed

Exit code 0 on failed require #479

popham opened this issue May 20, 2014 · 14 comments

Comments

@popham
Copy link

popham commented May 20, 2014

#88 specifically references failed tasks for exit(1) behavior, but I've got a gulpfile with a failed require that exits 0. Is this intended behavior?

@yocontra
Copy link
Member

That doesn't sound right. node should exit with the proper codes on error

@popham
Copy link
Author

popham commented May 21, 2014

I'm using gulp-chug. It's probably a problem over there.

@derekpeterson
Copy link

cc @robatron

@robatron
Copy link
Contributor

That's strange; gulp-chug should be emitting an error event when it encounters an exec error. I'll look into it soon.

@floatdrop
Copy link
Contributor

Any progress on this? I was trying to use gulp lint in precommit hook and it exited with code 0 and error in jshint task.

@yocontra
Copy link
Member

@floatdrop You'll have to process.exit(1) yourself until gulp 4

@yocontra
Copy link
Member

Actually nevermind, fixed in 3.8.4

@floatdrop
Copy link
Contributor

I will go with process.exit(1) for now. Gulp-cli needs some tests, because I still get 0 exit code.

@yocontra
Copy link
Member

@floatdrop What version are you on? Can I see your task? Need more info

@floatdrop
Copy link
Contributor

Sure:

// [13:25:59] CLI version 3.8.5
// [13:25:59] Local version 3.8.5
var gulp = require('gulp');
var jshint = require('gulp-jshint');

gulp.task('jshint', function () {
    return gulp.src('./api/**/*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(jshint.reporter('fail'));
});

gulp.task('lint', runSequence.bind(runSequence, 'jshint', 'jscs'));

/*
❯ gulp lint; echo $?
[13:27:08] Using gulpfile ~/bar.export/gulpfile.js
[13:27:08] Starting 'lint'...
[13:27:08] Starting 'jshint'...
[13:27:08] Finished 'lint' after 18 ms

/Users/floatdrop/bar.export/api/v1/test/schemas/quotelist.js
  line 8   col 5   Missing "use strict" statement.
  line 17  col 26  'tags' is already defined.
  line 18  col 5   Missing "use strict" statement.
  line 29  col 5   Missing "use strict" statement.

✖ 4 problems

0
*/

If I append .on('error', process.exit.bind(process, 1)) after .pipe(jshint.reporter('fail')) it will show:

❯ gulp lint; echo $?
...
✖ 4 problems

1

@yocontra
Copy link
Member

You failed to mention you're using runSequence to run the tasks. What is the exit code of gulp jshint?

@floatdrop
Copy link
Contributor

Without fail reporter:

❯ gulp jshint; echo $?
[10:49:44] Using gulpfile ~/bar.export/gulpfile.js
[10:49:44] Starting 'jshint'...

/Users/floatdrop/bar.export/api/v1/controllers/radio.js
  line 6  col 41  'next' is defined but never used.

✖ 1 problem

[10:49:45] Finished 'jshint' after 1.15 s
0

With fail reporter:

❯ gulp jshint; echo $?
[10:49:29] Using gulpfile ~/bar.export/gulpfile.js
[10:49:29] Starting 'jshint'...

/Users/floatdrop/bar.export/api/v1/controllers/radio.js
  line 6  col 41  'next' is defined but never used.

✖ 1 problem

0

@yocontra
Copy link
Member

I'm noticing that I never see a log saying that the task failed, which is why the exit code is 0. If any task fails throughout the duration of the process the switch gets flipped to be exit code 1. The fail reporter should absolutely be failing the task, I'll look into that more

@phated
Copy link
Member

phated commented Jun 30, 2014

I found a bug in orchestrator that wasn't emitting the errors on the orchestrator instance when returning a stream that errors. Thus, never setting the flag to true and not process.exit(1)ing. This has been fixed in orchestrator@0.3.4. Please npm update.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants