From aac7ebfaff64626526ce752bc5e2f0df01227a5f Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 13 Mar 2024 21:08:18 -0500 Subject: [PATCH] fix event imports for module --- scrapers/events.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scrapers/events.js b/scrapers/events.js index de1e836f..ec7b6eb7 100644 --- a/scrapers/events.js +++ b/scrapers/events.js @@ -1,9 +1,12 @@ -const superagent = require('superagent'); -const ical = require('ical.js'); -const fs = require('fs'); -const path = require("path"); +import superagent from 'superagent'; +import ical from 'ical.js'; +import fs from 'fs'; +import { fileURLToPath } from 'url'; +import { dirname, resolve } from 'path'; -const eventsFilepath = path.resolve(__dirname, "../src/data/events.json"); + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const eventsFilepath = resolve(__dirname, "../src/data/events.json"); const calendarURL = 'https://www.d125.org/data/calendar/icalcache/feed_E96D4A2A781C43699D5A4645042A0F79.ics'; // By default, the d125.org page blocks the superagent user agent string, but any other reasonable value works. const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0'