Change some other function to sync alternatives & put a / in the exists

This commit is contained in:
tgpethan 2020-06-15 08:30:16 +01:00
parent 076128d7f2
commit 828f53a8d1
1 changed files with 9 additions and 13 deletions

22
EUS.js
View File

@ -38,12 +38,10 @@ if (!fs.existsSync(__dirname + BASE_PATH + "/i")) {
// Makes the image-type file
if (fs.existsSync(__dirname + BASE_PATH + "image-type.json")) {
// Doesn't exist, create it.
fs.writeFile(`${__dirname}${BASE_PATH}/image-type.json`, '{\n}', function(err) {
if (err) throw err;
console.log("[EUS] Created image-type File!");
// File has been created, load it.
image_json = require(`${__dirname}${BASE_PATH}/image-type.json`);
});
fs.writeFileSync(`${__dirname}${BASE_PATH}/image-type.json`, '{}');
console.log("[EUS] Created image-type File!");
// File has been created, load it.
image_json = require(`${__dirname}${BASE_PATH}/image-type.json`);
} else {
// File already exists, load it.
image_json = require(`${__dirname}${BASE_PATH}/image-type.json`);
@ -52,13 +50,11 @@ if (fs.existsSync(__dirname + BASE_PATH + "image-type.json")) {
// Makes the config file
if (fs.existsSync(__dirname + BASE_PATH + "config.json")) {
// Config doesn't exist, make it.
fs.writeFile(`${__dirname}${BASE_PATH}/config.json`, '{\n\t"baseURL":"http://example.com/",\n\t"acceptedTypes": [\n\t\t".png",\n\t\t".jpg",\n\t\t".jpeg",\n\t\t".gif"\n\t],\n\t"uploadKey": ""\n}', function(err) {
if (err) throw err;
console.log("[EUS] Created config File!");
console.log("[EUS] Please edit the EUS Config file before restarting.");
// Config has been made, close framework.
process.exit(0);
});
fs.writeFileSync(`${__dirname}${BASE_PATH}/config.json`, '{\n\t"baseURL":"http://example.com/",\n\t"acceptedTypes": [\n\t\t".png",\n\t\t".jpg",\n\t\t".jpeg",\n\t\t".gif"\n\t],\n\t"uploadKey": ""\n}');
console.log("[EUS] Created config File!");
console.log("[EUS] Please edit the EUS Config file before restarting.");
// Config has been made, close framework.
process.exit(0);
} else {
eusConfig = require(`${__dirname}${BASE_PATH}/config.json`);
if (validateConfig(eusConfig)) console.log("[EUS] EUS config passed all checks");