From 44a060508bcf40589db80000d3018c44feb980a5 Mon Sep 17 00:00:00 2001 From: DeaDvey Date: Sat, 9 Aug 2025 13:00:07 +0100 Subject: [PATCH] Hitcount is now created by init.initialise() --- src/initialise.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/initialise.js b/src/initialise.js index 9be4c60..e74784e 100644 --- a/src/initialise.js +++ b/src/initialise.js @@ -11,14 +11,14 @@ export function initialise() { } catch (error) { console.log("Creating users file") - fs.writeFileSync(`../data/users.json`, `{\n"users": []\n}`) + fs.writeFileSync(`../data/users.json`, `[]`) } try { const posts = require("../data/posts.json"); } catch (error) { console.log("Creating posts file") - fs.writeFileSync(`../data/posts.json`, `{\n"posts": []\n}`) + fs.writeFileSync(`../data/posts.json`, `[]`) } try { const comments = require("../data/comments.json"); @@ -37,6 +37,15 @@ export function initialise() { console.log("Error copying file") }) } + try { + fs.readFileSync("../data/hitcount.txt") + } + catch (error) { + console.log("Creating hitcount file") + fs.writeFileSync("../data/hitcount.txt", "0", (err) => { + console.log("Error creating hitcount.txt") + }) + } console.log("Successfully initialised") process.exit(0) }