adm-zip
adm-zip copied to clipboard
support await / promise when call extractAllTo mehtod
I need to ensure that the extractAllTo method is completed before continuing to perform other program. Example:
const appPathTemp = join(moduleUpdatePath, DIST_MAP[moduleCode])
const zip = new AdmZip(filePath)
await zip.extractAllTo(appPathTemp)
But I find extractAllTo method not support. So how can i do? Thanks.
extractAllTo is not async. Your code should not advance unless that method is done. You can wrap that function call in another function that returns a promise and call await on that. Or use extractAllToAsync which takes a callback, and resolve your promise in the callback.
Unfortunately, when I made this 12 years ago, promises didn't exist in Javascript and now I can't just change the interface without breaking everyone's code.
extractAllTois not async. Your code should not advance unless that method is done. You can wrap that function call in another function that returns a promise and callawaiton that. Or useextractAllToAsyncwhich takes a callback, and resolve your promise in the callback.Unfortunately, when I made this 12 years ago, promises didn't exist in Javascript and now I can't just change the interface without breaking everyone's code.
Ok, let me try, Thanks.
I added await / promise support to the extractAllToAsync
you simply have to call function without callback
like:
await zip.extractAllToAsync(destination);