Skip to content

Commit

Permalink
fix: ensure folderPath exists
Browse files Browse the repository at this point in the history
  • Loading branch information
zxt-tzx committed Jan 22, 2024
1 parent 94b4dfd commit c6b8025
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,13 @@ async function load() {
"tt0258000",
];

// Create the folder if it doesn't exist
const folderPath = './data/imdb';
const imdbFolderExists = await fs.stat(folderPath).then(() => true).catch(() => false);
if(!imdbFolderExists) await fs.mkdir(folderPath);

for (const id of ids) {
const path = `./data/imdb/${id}.html`;
const path = `${folderPath}/${id}.html`;
const exists = await fs
.stat(path)
.then(() => true)
Expand Down

0 comments on commit c6b8025

Please sign in to comment.