Add success message

Also increase retries to 5 attempts.
This commit is contained in:
John Kleinschmidt 2017-10-05 16:31:54 -04:00
parent 54563dc94c
commit 0ae12c2b3d

View file

@ -2,6 +2,10 @@ const GitHub = require('github')
const github = new GitHub()
github.authenticate({type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN})
if (process.argv.length < 5) {
console.log('Usage: upload-to-github filePath fileName releaseId')
process.exit(1)
}
let filePath = process.argv[2]
let fileName = process.argv[3]
let releaseId = process.argv[4]
@ -14,15 +18,16 @@ let githubOpts = {
name: fileName
}
let retry = true
let retry = 0
function uploadToGitHub () {
github.repos.uploadAsset(githubOpts).then(() => {
console.log(`Successfully uploaded ${fileName} to GitHub.`)
process.exit()
}).catch((err) => {
if (retry) {
if (retry < 4) {
console.log(`Error uploading ${fileName} to GitHub, will retry. Error was:`, err)
retry = false
retry++
uploadToGitHub()
} else {
console.log(`Error retrying uploading ${fileName} to GitHub:`, err)