Guest User

Untitled

a guest
Dec 15th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. /*
  2. // file read and renaming code here
  3. */
  4.  
  5. // Zip files code below:
  6.  
  7. try {
  8. let files_converted = fs.readdirSync(OUTPUT_DIRECTORY);
  9. let file_converstion_async_array = [];
  10.  
  11. files_converted.forEach( (e , i) => {
  12. file_converstion_async_array.push( () => zip_Directory( `${OUTPUT_DIRECTORY}/${e}` , `${OUTPUT_DIRECTORY}/${e}.zip` ) );
  13. });
  14.  
  15. console.log('Files are being zipped...');
  16.  
  17. file_converstion_async_array.reduce( ( promise_chain , current_promise ) => {
  18.  
  19. return promise_chain.then( p_results => {
  20. return current_promise().then( c_result => {
  21. // console.log('ZIPPED');
  22. });
  23. });
  24.  
  25. } , Promise.resolve([]) ).then( () => {
  26. console.log('All Files have been zipped...');
  27. });
  28.  
  29. } catch (err) {
  30. console.error(err);
  31. }
  32.  
  33. // Finally render a new view
  34.  
  35. res.render("finish", {
  36. name: req.body.outputPath
  37. });
Add Comment
Please, Sign In to add comment