aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2020-10-01 18:26:45 +0200
committerMarvin Borner2020-10-01 18:26:45 +0200
commit83007e8e3b13ee1eb0670ebd04f4530394cbffc9 (patch)
treefe6217d9034068fefe8a7b6acfb20940eb2ebaff
parent1d898a3add62d201c3ce324f1feecd411d06d324 (diff)
Fixed Lars
-rw-r--r--db.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/db.js b/db.js
index dbef8f4..ab6a7f2 100644
--- a/db.js
+++ b/db.js
@@ -35,13 +35,16 @@ class DB {
}
initValues() {
- fs.readFile(__dirname + "/names.csv", "utf8", (err, data) => {
+ fs.readFile(__dirname + "/names.csv", "utf8", async (err, data) => {
if (err) throw err;
const classes = data.split("--");
const userPasswords = [];
- classes.forEach((clazz, classIndex) => {
+ console.log("Generating users");
+ for (const [classIndex, clazz] of classes.entries()) {
const students = clazz.split("\n");
- students.forEach(async (student) => {
+ // students.forEach(async (student) => {
+ for (const student of students) {
+ console.log(".");
// Fix undefined
if (student && student.length > 3) {
const [_, surname, name] = student.split(",");
@@ -58,9 +61,12 @@ class DB {
[username, names[0].replace("\r", ""), middlename, surname, password, classIndex + 1, 2]
);
}
- });
+ }
+ }
+ fs.writeFile(__dirname + "/users.json", JSON.stringify(userPasswords), (err) => {
+ if (err) console.error(err);
});
- fs.writeFile(__dirname + "/users.json", JSON.stringify(userPasswords), console.error);
+ console.log("Initialized users!");
});
}