Handle github token exception

pull/282/head
Amio 2019-06-07 09:59:26 +08:00
rodzic 3698d82ed1
commit 1a8386fa0f
1 zmienionych plików z 20 dodań i 4 usunięć

Wyświetl plik

@ -93,6 +93,14 @@ const queryGithub = query => {
}
async function singleStatus ({ owner, repo, ref = 'master' }: Args) {
if (!process.env.GH_TOKENS) {
return {
subject: 'github',
status: 'token required',
color: 'grey'
}
}
const statuses = await restGithub(`repos/${owner}/${repo}/commits/${ref}/status`)
switch (statuses.state) {
@ -130,12 +138,17 @@ async function singleStatus ({ owner, repo, ref = 'master' }: Args) {
}
async function release ({ owner, repo, channel }: Args) {
if (!process.env.GH_TOKENS) {
return {
subject: 'github',
status: 'token required',
color: 'grey'
}
}
const releases = await restGithub(`repos/${owner}/${repo}/releases`)
const [latest] = releases
const stable = releases.find(release => !release.prerelease)
if (!latest) {
if (!releases || !releases.length) {
return {
subject: 'release',
status: 'none',
@ -143,6 +156,9 @@ async function release ({ owner, repo, channel }: Args) {
}
}
const [latest] = releases
const stable = releases.find(release => !release.prerelease)
switch (channel) {
case 'stable':
return {