From 64490a53ff3c83d338567c45a123ebdc33142443 Mon Sep 17 00:00:00 2001 From: Julius Riegel Date: Fri, 12 Oct 2018 16:25:06 +0200 Subject: [PATCH] Code cleanup and comments - Added description for cleanup function - Removed unused variable clean and moved assignment of cleanup-function - removed index parameter from deleteFolder function in caching.js --- lib/caching.js | 2 +- server.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/caching.js b/lib/caching.js index a120d49..b3ede22 100644 --- a/lib/caching.js +++ b/lib/caching.js @@ -98,7 +98,7 @@ exports.cleanup = function () { */ var deleteFolder = function(p) { if( fs.existsSync(p) ) { - fs.readdirSync(p).forEach(function(file,index){ // get the contents of the directory + fs.readdirSync(p).forEach(function(file){ // get the contents of the directory var curPath = path.join(p, file); // create path by joining if(fs.lstatSync(curPath).isDirectory()) { // recurse deleteFolder(curPath); // call recursive diff --git a/server.js b/server.js index ee4f9b6..18c1fae 100644 --- a/server.js +++ b/server.js @@ -9,8 +9,6 @@ const fs = require('fs'), // own modules utils = require("./lib/utils"), prepro = require("./lib/preprocessor"), -// cleanup - clean = utils.Cleanup(cleanup), // args args = require('args-parser')(process.argv), // create an args parser // config file @@ -163,6 +161,9 @@ function getMount(uri) { return false; } +/** + * A cleanup-function that should only be called on process exit + */ function cleanup() { logger.info('Cleanup...'); prepro.cleanup(); // cleanup the preprocessor @@ -171,6 +172,7 @@ function cleanup() { // Executing the main function if (typeof require !== 'undefined' && require.main === module) { + utils.Cleanup(cleanup); // set the cleanup function logger.exceptions.handle( new winston.transports.File({ filename: './.log/frontserver-exceptions.log'