Skip to content

Commit a214db5

Browse files
authored
fix update-data.js script (#244)
1 parent d824da8 commit a214db5

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

scripts/update-data.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,19 @@ function updateSponsors() {
4848
logos[id] = 'sponsors/' + file
4949
}
5050
})
51-
fetch('https://opencollective.com/assemblyscript/members/all.json')
52-
.then(res => res.json())
51+
fetch('https://opencollective.com/assemblyscript/members/all.json', {
52+
headers: {
53+
accept: 'application/json'
54+
}
55+
})
56+
.then(async res => {
57+
const text = await res.text()
58+
try {
59+
return JSON.parse(text)
60+
} catch (err) {
61+
throw new Error('Invalid OpenCollective response')
62+
}
63+
})
5364
.then(json => {
5465
const seen = new Map()
5566
const sponsors = json
@@ -93,8 +104,8 @@ function updateSponsors() {
93104
fs.writeFileSync(__dirname + '/../data/sponsors.json', JSON.stringify(sponsors, null, 2))
94105
})
95106
.catch(err => {
96-
console.error(err.stack)
97-
process.exit(1)
107+
console.warn('Failed to update sponsors, keeping cached data')
108+
console.warn(err.message)
98109
})
99110
}
100111

0 commit comments

Comments
 (0)