From 01f3f5f2ab89432a253c24f76227b8f6855d8446 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Thu, 10 Mar 2022 10:40:10 +0200 Subject: Class parsing with any number of files with classes --- update.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'update.js') diff --git a/update.js b/update.js index a63ee3e..a78b57a 100644 --- a/update.js +++ b/update.js @@ -4,13 +4,14 @@ const parseClasses = require("./parseClasses.js").classes; const parse = require("./dbparse.js"); // Run this if you want to build the database from text files -async function buildDB(shiftfile = "./shifts.txt", classfile = "./classes.txt", dbcredentials) +async function buildDB(dbcredentials, shiftPath, ...classfiles) { - let shiftCont = await openFile(shiftfile); + let shiftCont = await openFile(shiftPath); const DB = new database.Database(JSON.parse(dbcredentials)); shiftCont = shiftCont.toString("utf-8").replaceAll("\r", ""); // \r because of the \r\n newline on windows which creates problems + await Promise.all([ - parseClasses(classfile[0], classfile[1], DB), + parseClasses(DB, ...classfiles), parse.build(shiftCont, DB) ]); return 0; @@ -20,6 +21,6 @@ exports.update = buildDB; // Example call: /* const openFile = require("./Functions/open.js").file; -const dbcredentials = openFile("../dblogin.txt"); -await updateDB.update("./shifts.txt", ["./Kurssitarjottimet/2016Classes.txt", "./Kurssitarjottimet/NewClasses.txt"], dbcredentials); +const dbcredentials = await openFile("../dblogin.txt"); +await updateDB.update(dbcredentials, "./shifts.txt", "./Kurssitarjottimet/2016Classes.txt", "./Kurssitarjottimet/NewClasses.txt"); */ \ No newline at end of file -- cgit v1.2.3