Updated lolisafe.js

Forgot to update this to take into account the changes in Cloudflare's
cache purge utility.
This commit is contained in:
Bobby Wibowo 2019-01-31 16:36:16 +07:00
parent d5c24165cf
commit e479ac53ff
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -204,10 +204,22 @@ const start = async () => {
if (config.cacheControl) {
process.stdout.write('Cache control enabled. Purging Cloudflare\'s cache ...')
const routes = config.pages.concat(['api/check'])
const result = await utils.purgeCloudflareCache(routes)
process.stdout.write(` ${result.errors.length ? 'ERROR' : `${result.files.length} OK`}!\n`)
if (result.errors.length)
result.errors.forEach(error => console.log(`CF: ${error}`))
const results = await utils.purgeCloudflareCache(routes)
let errored = false
let succeeded = 0
for (const result of results) {
if (!result.errors.length) {
if (!errored) {
errored = true
process.stdout.write(' ERROR!\n')
}
result.errors.forEach(error => console.log(`CF: ${error}`))
continue
}
succeeded += result.files.length
}
if (!errored)
process.stdout.write(` ${succeeded} OK!\n`)
}
// NODE_ENV=development yarn start