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
pull/8/head
Julius Riegel 6 years ago
parent 0f4c0de2d8
commit 64490a53ff

@ -98,7 +98,7 @@ exports.cleanup = function () {
*/ */
var deleteFolder = function(p) { var deleteFolder = function(p) {
if( fs.existsSync(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 var curPath = path.join(p, file); // create path by joining
if(fs.lstatSync(curPath).isDirectory()) { // recurse if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolder(curPath); // call recursive deleteFolder(curPath); // call recursive

@ -9,8 +9,6 @@ const fs = require('fs'),
// own modules // own modules
utils = require("./lib/utils"), utils = require("./lib/utils"),
prepro = require("./lib/preprocessor"), prepro = require("./lib/preprocessor"),
// cleanup
clean = utils.Cleanup(cleanup),
// args // args
args = require('args-parser')(process.argv), // create an args parser args = require('args-parser')(process.argv), // create an args parser
// config file // config file
@ -163,6 +161,9 @@ function getMount(uri) {
return false; return false;
} }
/**
* A cleanup-function that should only be called on process exit
*/
function cleanup() { function cleanup() {
logger.info('Cleanup...'); logger.info('Cleanup...');
prepro.cleanup(); // cleanup the preprocessor prepro.cleanup(); // cleanup the preprocessor
@ -171,6 +172,7 @@ function cleanup() {
// Executing the main function // Executing the main function
if (typeof require !== 'undefined' && require.main === module) { if (typeof require !== 'undefined' && require.main === module) {
utils.Cleanup(cleanup); // set the cleanup function
logger.exceptions.handle( logger.exceptions.handle(
new winston.transports.File({ new winston.transports.File({
filename: './.log/frontserver-exceptions.log' filename: './.log/frontserver-exceptions.log'

Loading…
Cancel
Save