From e479ac53ff0dfe307b4d72f70cb262d13e6751ef Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Thu, 31 Jan 2019 16:36:16 +0700 Subject: [PATCH] Updated lolisafe.js Forgot to update this to take into account the changes in Cloudflare's cache purge utility. --- lolisafe.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lolisafe.js b/lolisafe.js index 188e7c0..09385a1 100644 --- a/lolisafe.js +++ b/lolisafe.js @@ -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