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