How to change the unzipped file code to synchronization by nodejs

problem description

there are blocks in the project that need to be unzipped to process the file, and the code is now asynchronous. The return is empty when traversing the folder, how to change it to the synchronization code

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)
var fs = require ("fs");
var unzip = require (" unzip");
fs.createReadStream ("/ home/app/yyzz/zip/1.zip") .pipe (unzip.Extract ({path:"/ home/app/yyzz/image/"}));

what result do you expect? What is the error message actually seen?

May.10,2022

-just provide an idea, welcome correction-
you can use await


const unzip = require('unzip')
const fs = require('fs')

function unzipSync() {
    return new Promise((resolve, reject) => {
        fs.createReadStream('/home/app/yyzz/zip/1.zip').pipe(unzip.Extract({
            path: '/home/app/yyzz/image/'
        })).on('close', () => {
            console.log('stream close')
            resolve()
        }).on('error', (err) => {
            reject(err)
        })
    })
}

(async function () {
    try {
        await unzipSync()
    } catch (e) {
        console.log(e)
    }
    console.log('unzip success')
})()

just change it to async/await

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7ad88f-28ff0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7ad88f-28ff0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?