New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle orchestration aborted events #97
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,8 @@ function runSequence(gulp) { | |
var callBack = typeof taskSets[taskSets.length - 1] === 'function' ? taskSets.pop() : false; | ||
var currentTaskSet; | ||
|
||
var finished; | ||
|
||
if(options().ignoreUndefinedTasks) { | ||
// ignore missing tasks | ||
taskSets = filterArray(taskSets) | ||
|
@@ -67,8 +69,11 @@ function runSequence(gulp) { | |
} | ||
|
||
function finish(e) { | ||
if (finished) return; | ||
|
||
gulp.removeListener('task_stop', onTaskEnd); | ||
gulp.removeListener('task_err', onError); | ||
gulp.removeListener('err', onGulpError); | ||
|
||
var error; | ||
if(e && e.err) { | ||
|
@@ -96,6 +101,12 @@ function runSequence(gulp) { | |
} | ||
} | ||
|
||
function onGulpError(e) { | ||
if (e.message === 'orchestration aborted') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove space |
||
finish(e); | ||
} | ||
}; | ||
|
||
function runNextSet() { | ||
if(taskSets.length) { | ||
var command = taskSets.shift(); | ||
|
@@ -113,6 +124,7 @@ function runSequence(gulp) { | |
|
||
gulp.on('task_stop', onTaskEnd); | ||
gulp.on('task_err', onError); | ||
gulp.on('err', onGulpError); | ||
|
||
runNextSet(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,6 +260,40 @@ describe('runSequence', function() { | |
|
||
called.should.eql(true); | ||
}) | ||
|
||
it('should pass error if gulp execution halted in second execution', function(done) { | ||
const stopTask = gulp.task('stopTask', function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To ensure backwards compatibility, since this codebase is older, let's leave this as a |
||
if (stopTask.shouldStop) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's several spaces between the keywords and parentheses in here. |
||
gulp.stop(); | ||
} | ||
}); | ||
|
||
stopTask.shouldStop = false; | ||
|
||
var outerTask = gulp.task('outerTask', function(cb) { | ||
runSequence('task2', ['stopTask', 'task3'], function(err) { | ||
if (stopTask.shouldStop) { | ||
try { | ||
should(err).be.ok; | ||
err.message.should.equal('orchestration aborted'); | ||
} catch (e) { | ||
cb(); | ||
return done(e); | ||
} | ||
cb(); | ||
done(); | ||
} else { | ||
cb(); | ||
} | ||
}); | ||
}); | ||
|
||
gulp.start('outerTask', function() { | ||
stopTask.shouldStop = true; | ||
task3.shouldPause = true; | ||
gulp.start('outerTask'); | ||
}); | ||
}) | ||
}); | ||
|
||
describe('Options', function() { | ||
|
@@ -275,4 +309,4 @@ describe('runSequence', function() { | |
}); | ||
}); | ||
|
||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finished appears to never be set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please match the style of this codebase, no spaces between language keywords (
if
,catch
, etc) and the parentheses.