diff --git a/main.ts b/main.ts index d225350..523f61e 100644 --- a/main.ts +++ b/main.ts @@ -103,8 +103,6 @@ const options = { async run() { const db = await createDatabase(args.values.db!); const library = createLibrary(db); - const browser = await chromium.launch(); - const platform = createPlatform({ db, browser }); const books: Array = []; if (args.values.download === "all") { @@ -124,12 +122,13 @@ const options = { } for (const book of books) { + const browser = await chromium.launch(); + const platform = createPlatform({ db, browser }); const dir = `${args.values["out-dir"]!}/${book.id}`; await platform.download(dir, book); await library.archive(dir, args.values["out-dir"]!, book); + await browser.close(); } - - await browser.close(); }, }, json: {