mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 07:11:33 +00:00
Updated cfpurge.js
This will now intended for manually purging uploads only.
This commit is contained in:
parent
e74fb3811f
commit
1c23a8a6eb
@ -1,30 +1,25 @@
|
|||||||
// This is sorta no longer in use since lolisafe.js will do this automatically
|
|
||||||
// everytime is launches.
|
|
||||||
|
|
||||||
const { stripIndents } = require('./_utils')
|
const { stripIndents } = require('./_utils')
|
||||||
const utils = require('./../controllers/utilsController')
|
const utils = require('./../controllers/utilsController')
|
||||||
const config = require('./../config')
|
|
||||||
|
|
||||||
const cfpurge = {}
|
const cfpurge = {}
|
||||||
|
|
||||||
cfpurge.do = async () => {
|
cfpurge.do = async () => {
|
||||||
const location = process.argv[1].replace(process.cwd() + '/', '')
|
const location = process.argv[1].replace(process.cwd() + '/', '')
|
||||||
const args = process.argv.slice(2)
|
const args = process.argv.slice(2)
|
||||||
if (args.includes('--help') || args.includes('-h'))
|
if (!args.length || args.includes('--help') || args.includes('-h'))
|
||||||
return console.log(stripIndents(`
|
return console.log(stripIndents(`
|
||||||
Purge Cloudflare's cache.
|
Purge Cloudflare's cache.
|
||||||
|
|
||||||
Usage:\nnode ${location} [...filename]
|
Usage:\nnode ${location} ...filename
|
||||||
|
|
||||||
filename:
|
filename:
|
||||||
File names (as in uploads) separated by space (will automatically include their thumbs if available).
|
Upload names separated by space (will automatically include their thumbs if available).
|
||||||
If not provided, this will default to frontend pages listed in "pages" array in config.js.
|
|
||||||
`))
|
`))
|
||||||
|
|
||||||
const filenames = args.length ? args : config.pages.concat(['api/check'])
|
const results = await utils.purgeCloudflareCache(args, true)
|
||||||
const result = await utils.purgeCloudflareCache(filenames, Boolean(args.length))
|
for (const result of results)
|
||||||
if (result.errors.length)
|
if (result.errors.length)
|
||||||
return result.errors.forEach(error => console.error(`CF: ${error}`))
|
result.errors.forEach(error => console.error(`CF: ${error}`))
|
||||||
else
|
else
|
||||||
console.log(`URLs:\n${result.files.join('\n')}\n\nSuccess: ${result.success}`)
|
console.log(`URLs:\n${result.files.join('\n')}\n\nSuccess: ${result.success}`)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user