Skip to content

Commit 5fdf79b

Browse files
committed
refactor: validate config before running
1 parent f6b85be commit 5fdf79b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/core.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { PlaywrightCrawler } from "crawlee";
33
import { readFile, writeFile } from "fs/promises";
44
import { glob } from "glob";
5-
import { Config } from "./config.js";
5+
import {Config, configSchema} from "./config.js";
66
import { Page } from "playwright";
77

88
let pageCounter = 0;
@@ -46,6 +46,8 @@ export async function waitForXPath(page: Page, xpath: string, timeout: number) {
4646
}
4747

4848
export async function crawl(config: Config) {
49+
configSchema.parse(config);
50+
4951
if (process.env.NO_CRAWL !== "true") {
5052
// PlaywrightCrawler crawls the web using a headless
5153
// browser controlled by the Playwright library.
@@ -111,6 +113,8 @@ export async function crawl(config: Config) {
111113
}
112114

113115
export async function write(config: Config) {
116+
configSchema.parse(config);
117+
114118
const jsonFiles = await glob("storage/datasets/default/*.json", {
115119
absolute: true,
116120
});

0 commit comments

Comments
 (0)