mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 12:27:49 +00:00
Delay status completion until there is a valid job ID.
This commit is contained in:
@@ -246,6 +246,17 @@ function getOption(name, defaultValue) {
|
|||||||
}, defaultValue);
|
}, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if `value` is a job ID.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to check.
|
||||||
|
* @returns {boolean} Returns `true` if `value` is a job ID, else `false`.
|
||||||
|
*/
|
||||||
|
function isJobId(value) {
|
||||||
|
return reJobId.test(value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes an inline message to standard output.
|
* Writes an inline message to standard output.
|
||||||
*
|
*
|
||||||
@@ -395,7 +406,7 @@ function onJobStart(error, res, body) {
|
|||||||
* @param {Object} body The response body JSON object.
|
* @param {Object} body The response body JSON object.
|
||||||
*/
|
*/
|
||||||
function onJobStatus(error, res, body) {
|
function onJobStatus(error, res, body) {
|
||||||
var completed = _.result(body, 'completed'),
|
var completed = _.result(body, 'completed', false),
|
||||||
data = _.first(_.result(body, 'js tests')),
|
data = _.first(_.result(body, 'js tests')),
|
||||||
jobId = _.result(data, 'job_id', null),
|
jobId = _.result(data, 'job_id', null),
|
||||||
jobResult = _.result(data, 'result', null),
|
jobResult = _.result(data, 'result', null),
|
||||||
@@ -416,10 +427,12 @@ function onJobStatus(error, res, body) {
|
|||||||
if (!this.running || this.stopping) {
|
if (!this.running || this.stopping) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (reJobId.test(jobId)) {
|
if (isJobId(jobId)) {
|
||||||
this.id = jobId;
|
this.id = jobId;
|
||||||
this.result = jobResult;
|
this.result = jobResult;
|
||||||
this.url = jobUrl;
|
this.url = jobUrl;
|
||||||
|
} else {
|
||||||
|
completed = false;
|
||||||
}
|
}
|
||||||
this.emit('status', jobStatus);
|
this.emit('status', jobStatus);
|
||||||
|
|
||||||
@@ -533,7 +546,7 @@ Job.prototype.remove = function(callback) {
|
|||||||
this.removing = true;
|
this.removing = true;
|
||||||
return this.stop(function() {
|
return this.stop(function() {
|
||||||
var onRemove = _.bind(onJobRemove, this);
|
var onRemove = _.bind(onJobRemove, this);
|
||||||
if (!reJobId.test(this.id)) {
|
if (!this.id) {
|
||||||
_.defer(onRemove);
|
_.defer(onRemove);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -646,7 +659,7 @@ Job.prototype.stop = function(callback) {
|
|||||||
this.checking = false;
|
this.checking = false;
|
||||||
}
|
}
|
||||||
var onStop = _.bind(onGenericStop, this);
|
var onStop = _.bind(onGenericStop, this);
|
||||||
if (!this.running || !reJobId.test(this.id)) {
|
if (!this.running || !this.id) {
|
||||||
_.defer(onStop);
|
_.defer(onStop);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user