From 2607a1148700cbb0c7c854458004c66584dce961 Mon Sep 17 00:00:00 2001 From: SollyBunny Date: Fri, 2 Sep 2022 14:02:48 +0000 Subject: [PATCH] update --- index.js | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) mode change 100644 => 100755 index.js diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 4eab334..7e910eb --- a/index.js +++ b/index.js @@ -100,7 +100,7 @@ global.log = (type, msg) => { case MISC: name = "MISC"; break; default : name = "UNKN"; } - console.log(`\u001b[${type}m[${name}]\u001b[0m ${msg}`); + console.log(`${Date.now()} \u001b[${type}m[${name}]\u001b[0m ${msg}`); if (type === FATL) process.exit(1); }; @@ -160,25 +160,6 @@ let conf; } // Check conf.NAME is valid if (conf.NAME === undefined) conf.NAME = DEFAULTCONF.NAME; - // Check conf.FILESDIR is valid - if (conf.FILESDIR === undefined) { - log(WARN, `Define "FILESDIR" in "${CONFIGDIR}"`); - conf.FILESDIR = DEFAULTCONF.FILESDIR; - } - if (conf.FILESDIR[conf.FILESDIR.length - 1] !== "/") { // conf.FILESDIR must have "/" at the end - conf.FILESDIR += "/"; - } - if (fs.existsSync(conf.FILESDIR)) { - if (fs.statSync(conf.FILESDIR).isFile()) { - log(FATL, `File directory "${conf.FILESDIR}" is a file`); - // TODO rename file and put it in all - } - checkfilesdirstructure(); - } else { - fs.mkdirSync(conf.FILESDIR); - fs.mkdirSync(`${conf.FILESDIR}all`); - log(INFO, `Creating "${conf.FILESDIR}" as it didn't exist`); - } // Check conf.SCRIPTSis valid if (conf.SCRIPTS === undefined) { conf.SCRIPTS = DEFAULTCONF.SCRIPTS; @@ -329,7 +310,27 @@ let conf; } }); } - + +// Check conf.FILESDIR is valid + if (conf.FILESDIR === undefined) { + log(WARN, `Define "FILESDIR" in "${CONFIGDIR}"`); + conf.FILESDIR = DEFAULTCONF.FILESDIR; + } + if (conf.FILESDIR[conf.FILESDIR.length - 1] !== "/") { // conf.FILESDIR must have "/" at the end + conf.FILESDIR += "/"; + } + if (fs.existsSync(conf.FILESDIR)) { + if (fs.statSync(conf.FILESDIR).isFile()) { + log(FATL, `File directory "${conf.FILESDIR}" is a file`); + // TODO rename file and put it in all + } + checkfilesdirstructure(); + } else { + fs.mkdirSync(conf.FILESDIR); + fs.mkdirSync(`${conf.FILESDIR}all`); + log(INFO, `Creating "${conf.FILESDIR}" as it didn't exist`); + } + // Watch for changes in conf.FILESDIR fileventignore = 0; fs.watch(conf.FILESDIR, { persistent: false }, (event, file) => { @@ -378,13 +379,13 @@ function listdir(dir) {
` + ( // files.map((i) => { if (fs.statSync(`${dir}/${i}`).isDirectory()) { - return `Γ°ΕΈβ€œΒ ${i} (dir)`; + return `πŸ“ ${i} (dir)`; } else if (conf.SCRIPTS.indexOf(i) !== -1) { - return `Γ°ΕΈβ€œΕ“ ${i} (script)`; + return `πŸ“œ ${i} (script)`; } else if (conf.REDIRECTS.indexOf(i) !== -1) { - return `🔗 ${i} (redirect)`; + return `πŸ”— ${i} (redirect)`; } else { - return `Γ°ΕΈβ€œβ€˜ ${i}`; + return `πŸ“‘ ${i}`; } }).join("
") ); @@ -479,7 +480,7 @@ function HTTPhandle(req, res) {

Files:

${files} - Γ°ΕΈβ€œβ€˜ + πŸ“‘ `); break;