@@ -2,28 +2,23 @@ import tl = require('azure-pipelines-task-lib/task');
22import path = require( 'path' ) ;
33import Q = require( 'q' ) ;
44import fs = require( 'fs' ) ;
5- import StreamZip = require( 'node-stream-zip' ) ;
6- var DecompressZip = require ( 'decompress-zip' ) ;
5+ import StreamZip from 'node-stream-zip' ;
76var archiver = require ( 'archiver' ) ;
87
98export async function unzip ( zipLocation , unzipLocation ) {
109 var defer = Q . defer ( ) ;
1110 if ( tl . exist ( unzipLocation ) ) {
1211 tl . rmRF ( unzipLocation ) ;
1312 }
14- var unzipper = new DecompressZip ( zipLocation ) ;
15- tl . debug ( 'extracting ' + zipLocation + ' to ' + unzipLocation ) ;
16- unzipper . on ( 'error' , function ( error ) {
17- defer . reject ( error ) ;
18- } ) ;
19- unzipper . on ( 'extract' , function ( log ) {
20- tl . debug ( 'extracted ' + zipLocation + ' to ' + unzipLocation + ' Successfully' ) ;
21- defer . resolve ( unzipLocation ) ;
22- } ) ;
23- unzipper . extract ( {
24- path : unzipLocation
25- } ) ;
26- return defer . promise ;
13+ tl . mkdirP ( unzipLocation ) ;
14+ const zip = new StreamZip . async ( { file : zipLocation } ) ;
15+ zip . extract ( null , unzipLocation ) . then ( ( ) => {
16+ zip . close ( ) ;
17+ defer . resolve ( ) ;
18+ } ) . catch ( ( error ) => {
19+ console . log ( `error extracting ${ zipLocation } : ${ error } ` ) ;
20+ defer . reject ( error ) ;
21+ } )
2722}
2823
2924export async function archiveFolder ( folderPath , targetPath , zipName ) {
@@ -53,17 +48,16 @@ export async function archiveFolder(folderPath, targetPath, zipName) {
5348 */
5449export async function getArchivedEntries ( archivedPackage : string ) {
5550 var deferred = Q . defer ( ) ;
56- var unzipper = new DecompressZip ( archivedPackage ) ;
57- unzipper . on ( 'error' , function ( error ) {
51+ const zip = new StreamZip . async ( { file : archivedPackage } ) ;
52+ zip . entries ( ) . then ( entries => {
53+ var packageConmponent = {
54+ 'entries' : Object . keys ( entries )
55+ }
56+ zip . close ( ) ;
57+ deferred . resolve ( packageConmponent ) ;
58+ } ) . catch ( error => {
5859 deferred . reject ( error ) ;
59- } ) ;
60- unzipper . on ( 'list' , function ( files ) {
61- var packageComponent = {
62- "entries" :files
63- } ;
64- deferred . resolve ( packageComponent ) ;
65- } ) ;
66- unzipper . list ( ) ;
60+ } )
6761 return deferred . promise ;
6862}
6963
0 commit comments