-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
46 lines (38 loc) · 1.28 KB
/
index.ts
File metadata and controls
46 lines (38 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { PageCaptureRunner } from "./src/pageCaptureRunner"
import { loadUrlsFromFile } from "./src/loadUrlsFromFile"
import { config } from "./src/config"
import { FileLogger, RunFolderLoggingObserver } from "./src/fileLogger"
const originalConsoleLog = console.log.bind(console)
const originalConsoleWarn = console.warn.bind(console)
const originalConsoleError = console.error.bind(console)
const fileLogger = FileLogger.getInstance()
const runFolderObserver = new RunFolderLoggingObserver(fileLogger)
console.log = (...args: unknown[]) => {
originalConsoleLog(...args)
fileLogger.record("log", args)
}
console.warn = (...args: unknown[]) => {
originalConsoleWarn(...args)
fileLogger.record("warn", args)
}
console.error = (...args: unknown[]) => {
originalConsoleError(...args)
fileLogger.record("error", args)
}
async function main() {
let urls: string[]
try {
urls = await loadUrlsFromFile(config.LINKS_FILE)
} catch (error) {
console.error(error instanceof Error ? error.message : "Failed to load links from links.txt.")
process.exit(1)
return
}
const runner = new PageCaptureRunner(urls)
runner.registerRunFolderObserver(runFolderObserver)
await runner.run()
}
main().catch((error) => {
console.error("Unexpected error:", error)
process.exit(1)
})