Make more consistent use of async/await (#2219)

In #2028 I suggested that we update as much of the code as possible to make consistent use of async await. This snags a bunch of the utility code and attempts to do that.
This commit is contained in:
Paul Melnikow
2018-10-28 11:34:47 -04:00
committed by GitHub
parent 60592b8547
commit 6e51178e73
6 changed files with 166 additions and 153 deletions

View File

@@ -5,6 +5,7 @@
*/
'use strict'
const { promisify } = require('util')
const request = require('request')
const uniq = require('lodash.uniq')
const { listCompare } = require('./version')
@@ -216,26 +217,23 @@ function versionReduction(versions, phpReleases) {
return versions.join(', ')
}
function getPhpReleases(githubApiProvider, cb) {
regularUpdate(
{
url: '/repos/php/php-src/git/refs/tags',
intervalMillis: 24 * 3600 * 1000, // 1 day
scraper: tags =>
uniq(
tags
// only releases
.filter(
tag => tag.ref.match(/^refs\/tags\/php-\d+\.\d+\.\d+$/) != null
)
// get minor version of release
.map(tag => tag.ref.match(/^refs\/tags\/php-(\d+\.\d+)\.\d+$/)[1])
),
request: (url, options, cb) =>
githubApiProvider.request(request, url, {}, cb),
},
cb
)
function getPhpReleases(githubApiProvider) {
return promisify(regularUpdate)({
url: '/repos/php/php-src/git/refs/tags',
intervalMillis: 24 * 3600 * 1000, // 1 day
scraper: tags =>
uniq(
tags
// only releases
.filter(
tag => tag.ref.match(/^refs\/tags\/php-\d+\.\d+\.\d+$/) != null
)
// get minor version of release
.map(tag => tag.ref.match(/^refs\/tags\/php-(\d+\.\d+)\.\d+$/)[1])
),
request: (url, options, cb) =>
githubApiProvider.request(request, url, {}, cb),
})
}
module.exports = {