mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-26 05:00:06 +02:00

Update some scripts to use Script Runner GitOrigin-RevId: aaa11f94dcfd328c158bb02d1b9fb2adfb1bb146
42 lines
1 KiB
JavaScript
42 lines
1 KiB
JavaScript
import checkSanitizeOptions from './checkSanitizeOptions.mjs'
|
|
import Scrape from './scrape.mjs'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { scriptRunner } from '../../lib/ScriptRunner.mjs'
|
|
|
|
const { getAllPagesAndCache, scrapeAndCachePage } = Scrape
|
|
|
|
async function main() {
|
|
const BASE_URL = process.argv.pop()
|
|
if (!BASE_URL.startsWith('http')) {
|
|
throw new Error(
|
|
'Usage: node scripts/learn/checkSanitize/index.mjs https://LEARN_WIKI'
|
|
)
|
|
}
|
|
|
|
const pages = await getAllPagesAndCache(BASE_URL)
|
|
|
|
for (const page of pages) {
|
|
try {
|
|
const parsed = await scrapeAndCachePage(BASE_URL, page)
|
|
|
|
const title = parsed.title
|
|
const text = parsed.text ? parsed.text['*'] : ''
|
|
|
|
checkSanitizeOptions(page, title, text)
|
|
} catch (e) {
|
|
console.error('---')
|
|
console.error(page, e)
|
|
throw e
|
|
}
|
|
}
|
|
}
|
|
|
|
if (fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
try {
|
|
await scriptRunner(main)
|
|
process.exit(0)
|
|
} catch (error) {
|
|
console.error(error)
|
|
process.exit(1)
|
|
}
|
|
}
|