Fixed init.initialise() checking for .js files as opposed to .json files
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import·{·createRequire·}·from·'module';
|
||||
const·require·=·createRequire(import.meta.url)
|
||||
import { createRequire } from 'module';
|
||||
const require = createRequire(import.meta.url)
|
||||
// Initialise the program by creating users.js, comments.js, posts.js and config.js
|
||||
// All require default content in them to start off with
|
||||
// Then exit successfully
|
||||
@@ -7,7 +7,7 @@ const·require·=·createRequire(import.meta.url)
|
||||
export function initialise() {
|
||||
const fs = require("fs");
|
||||
try {
|
||||
const users = require("../data/users.js");
|
||||
const users = require("../data/users.json");
|
||||
}
|
||||
catch (error) {
|
||||
console.log("Creating users file")
|
||||
@@ -28,12 +28,12 @@ export function initialise() {
|
||||
fs.writeFileSync(`../data/comments.json`, `{\n"comments": [],\n"counter": 0}`)
|
||||
}
|
||||
try {
|
||||
const config = require("../data/config.js");
|
||||
const config = require("../data/config.json");
|
||||
}
|
||||
catch (error) {
|
||||
console.log("Copying the example config to config.js")
|
||||
console.log("!!! PLEASE MODIFY config.js TO YOUR NEEDS !!!")
|
||||
fs.copyFile('example-config.js', 'config.js', (err) => {
|
||||
fs.copyFile('example-config.json', 'config.json', (err) => {
|
||||
console.log("Error copying file")
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user