const rimraf = require('rimraf')

/**
 * Clean up all workpath files and remove folder
 */
module.exports = function(job, settings) {
    if (settings.skipCleanup) {
        settings.logger.log(`[${job.uid}] skipping the clean up...`);
        return Promise.resolve(job)
    }

    return new Promise((resolve) => {
        settings.logger.log(`[${job.uid}] cleaning up...`);
        if(!job.workpath){ job.workpath = settings.workpath.concat("/", job.uid, "/")}//Sometimes this attribute (workpath) was undefined.
       	rimraf(job.workpath, {glob: false}, (err) => {
            if (!err) {
                settings.logger.log(`[${job.uid}] Temporary AfterEffects project deleted. If you want to inspect it for debugging, use "--skip-cleanup"`)
            } else {
                settings.logger.log(`[${job.uid}] Temporary AfterEffects could not be deleted. (Error: ${err.code}). Please delete the folder manually: ${job.workpath}`)
            }
            resolve(job)
        })    
    })
};


@@ -378,18 +378,88 @@
         
-if
+%0A        // sometimes this attribute (workpath) is undefined%0A        if 
 (!job.wo
@@ -465,17 +465,30 @@
 orkpath)
-%7B
+ %7B%0A           
  job.wor
@@ -520,19 +520,19 @@
 .concat(
-%22/%22
+'/'
 , job.ui
@@ -538,74 +538,40 @@
 id, 
-%22/%22)%7D//Sometimes this attribute (workpath) was undefined.%0A       %09
+'/')%0A        %7D%0A       %09%0A        
 rimr
@@ -1031,20 +1031,16 @@
       %7D)
-    
 %0A    %7D)%0A

Update cleanup.js