1 | const pRetry = require('p-retry');
|
2 |
|
3 | /**
|
4 | * Return the list of pending job numbers.
|
5 | *
|
6 | * @param {Array} jobs Travis jobs to verify
|
7 | * @return {Array<String>} list of pending job numbers or an empty Array if all the jobs are successfuly completed
|
8 | * @throws {AbortError} if there a failed job
|
9 | */
|
10 | module.exports = jobs =>
|
11 | jobs.reduce((pendingJobs, job) => {
|
12 | if (!job.allow_failure && job.state !== 'passed') {
|
13 | if (job.state === 'errored' || job.state === 'failed') {
|
14 | // Throw an abort error to stop checking the job state and exit
|
15 | throw new pRetry.AbortError(job.number);
|
16 | }
|
17 | pendingJobs.push(job.number);
|
18 | }
|
19 | return pendingJobs;
|
20 | }, []);
|