q2s2t / node-7z

A Node.js wrapper for 7-Zip
https://www.npmjs.org/package/node-7z
ISC License
177 stars 60 forks source link

Why did not into then #120

Open jiucheng-front opened 2 years ago

jiucheng-front commented 2 years ago

On node-7z(0.2.0), As follows, why did not into then? It into catch, But add success sevenZip.add('WJF001.zip', allLogPath).progress(function(res) { console.log(res, '111'); }).then(function() { console.log('222'); }).catch(function(err) { console.log(err, '333'); });

twok020101 commented 6 months ago

My understanding is, it's not async/await (promise) function. This library triggers events from childProcess which is then retrieved using 'on' method. Hence '.then' or '.catch' wont work, instead you can use

myStream.on('err',(err)=>{console.log(err)}); myStream.on('end',(res)=>{consoole.log('222'});