2019-01-06 06:27:17 +00:00
|
|
|
const { stripIndents } = require('./_utils')
|
|
|
|
const utils = require('./../controllers/utilsController')
|
|
|
|
|
2019-09-08 01:56:29 +00:00
|
|
|
;(async () => {
|
2019-01-06 06:27:17 +00:00
|
|
|
const location = process.argv[1].replace(process.cwd() + '/', '')
|
|
|
|
const args = process.argv.slice(2)
|
2019-09-08 01:56:29 +00:00
|
|
|
|
2019-01-31 09:44:04 +00:00
|
|
|
if (!args.length || args.includes('--help') || args.includes('-h'))
|
2019-01-06 06:27:17 +00:00
|
|
|
return console.log(stripIndents(`
|
|
|
|
Purge Cloudflare's cache.
|
|
|
|
|
2019-09-08 01:56:29 +00:00
|
|
|
Usage:
|
|
|
|
node ${location} ...filename
|
2019-01-06 06:27:17 +00:00
|
|
|
|
|
|
|
filename:
|
2019-01-31 09:44:04 +00:00
|
|
|
Upload names separated by space (will automatically include their thumbs if available).
|
2019-01-06 06:27:17 +00:00
|
|
|
`))
|
|
|
|
|
2019-01-31 09:49:14 +00:00
|
|
|
const results = await utils.purgeCloudflareCache(args, true, true)
|
2019-09-08 01:56:29 +00:00
|
|
|
|
2019-01-31 09:44:04 +00:00
|
|
|
for (const result of results)
|
|
|
|
if (result.errors.length)
|
|
|
|
result.errors.forEach(error => console.error(`CF: ${error}`))
|
|
|
|
else
|
|
|
|
console.log(`URLs:\n${result.files.join('\n')}\n\nSuccess: ${result.success}`)
|
2019-09-08 01:56:29 +00:00
|
|
|
})()
|
|
|
|
.then(() => process.exit(0))
|
|
|
|
.catch(error => {
|
|
|
|
console.error(error)
|
|
|
|
process.exit(1)
|
|
|
|
})
|