diff --git a/app.js b/app.js index e43fc72f75a3396bb6f0004b7152eda2ce75d9d0..478e55ee9afdc076031d3c3636ea7ffc45a474ce 100644 --- a/app.js +++ b/app.js @@ -174,7 +174,10 @@ function streamFilesToZip(){ backendContent = fs.readFileAsync(file.path); backendContent.then(function(data){ addBackendToZip(data).then(function(){ - resolve(finishedArray.push('backend finished')); + finishedArray.push('backend finished'); + if(finishedArray.length === promiseArray.length){ + resolve(zip); + } }) @@ -193,7 +196,10 @@ function streamFilesToZip(){ }).on('finish', function(){ console.log('zip in frontend:', zip); - resolve(finishedArray.push('frontend finished')); + finishedArray.push('frontend finished'); + if(finishedArray.length === promiseArray.length){ + resolve(zip); + } console.log('finishedArray in frontend:', finishedArray); @@ -213,24 +219,10 @@ function streamFilesToZip(){ }) } -function collectFilesToZip(finishedArray){ - console.log('in collectFilesToZip'); - console.log('finishedArray.length:', finishedArray.length); - console.log('promiseArray.length:', promiseArray.length); - return new Promise((resolve,reject)=> { - if(finishedArray.length === promiseArray.length){ - console.log('in resolve()'); - resolve(zip); - } - }) -} function finalizeZip(){ - return streamFilesToZip().then(function(){ - return collectFilesToZip(finishedArray).then(function(zip){ - + return streamFilesToZip().then(function(zip){ return createZip(zip) - }) }).catch(function(error) {let response = 'There was an error during your build. ' + 'Please contact "explorviz-developers-request@listserv.dfn.de" ' +