@@ -111,52 +111,92 @@ export class VSIXEditor {
111111 tl . debug ( "Editing started" ) ;
112112 }
113113
114- private extractArchive ( input : string , output : string ) : void {
115- if ( tl . osType ( ) === "Windows_NT" ) {
114+ private extractArchive ( vsix : string , tmpPath : string ) : void {
115+ const cwd = tl . cwd ( ) ;
116+
117+ if ( tl . getPlatform ( ) === tl . Platform . Windows ) {
116118 const sevenZip = require ( "7zip-bin-win" ) ;
117119 const zip = new tr . ToolRunner ( sevenZip . path7za ) ;
118- zip . arg ( "x" ) ;
119- zip . arg ( input ) ; // file to extract
120- zip . arg ( `-o${ output } ` ) ; // redirect output to dir
121- zip . arg ( "-y" ) ; // assume yes on all queries
122- zip . arg ( "-spd" ) ; // disable wildcards
123- zip . arg ( "-aoa" ) ; // overwrite all
120+
121+ if ( tl . getVariable ( "PREVIEW_FAST_UPDATE" ) === "true" )
122+ {
123+ zip . arg ( "x" ) ;
124+ zip . arg ( vsix ) ; // file to extract
125+ zip . arg ( `-o${ tmpPath } ` ) ; // redirect output to dir
126+ zip . arg ( "task.json" ) ;
127+ zip . arg ( "task.loc.json" ) ;
128+ zip . arg ( "extension.vsixmanifest" ) ;
129+ zip . arg ( "extension.vsomanifest" ) ;
130+ zip . arg ( "-y" ) ; // assume yes on all queries
131+ zip . arg ( "-r" ) ; // recurse
132+ zip . arg ( "-bd" ) ; // disable progress indicator
133+ zip . arg ( "-aoa" ) ; // overwrite all
134+ zip . arg ( "-spd" ) ; // disable wildcards
135+ }
136+ else
137+ {
138+ zip . arg ( "x" ) ;
139+ zip . arg ( vsix ) ; // file to extract
140+ zip . arg ( `-o${ tmpPath } ` ) ; // redirect output to dir
141+ zip . arg ( "-y" ) ; // assume yes on all queries
142+ zip . arg ( "-spd" ) ; // disable wildcards
143+ zip . arg ( "-aoa" ) ; // overwrite all
144+ }
124145 zip . execSync ( ) ;
125146 }
126147 else {
127148 const zip = new tr . ToolRunner ( tl . which ( "unzip" , true ) ) ;
128149 zip . arg ( "-o" ) ; // overwrite all
129150 zip . arg ( "-d" ) ; // redirect output to
130- zip . arg ( output ) ; // output directory
131- zip . arg ( input ) ; // file to extract
151+ zip . arg ( tmpPath ) ; // output directory
152+ zip . arg ( vsix ) ; // file to extract
132153 zip . execSync ( ) ;
133154 }
155+ tl . cd ( cwd ) ;
134156 }
135157
136- private createArchive ( input : string , output : string ) : void {
137- if ( tl . osType ( ) === "Windows_NT" ) {
158+ private createArchive ( originalVsix : string , tmpPath : string , targetVsix : string ) : void {
159+ const cwd = tl . cwd ( ) ;
160+
161+ if ( tl . getPlatform ( ) === tl . Platform . Windows ) {
138162 const sevenZip = require ( "7zip-bin-win" ) ;
139163 const zip = new tr . ToolRunner ( sevenZip . path7za ) ;
140- zip . arg ( "a" ) ;
141- zip . arg ( output ) ; // redirect output to file
142- zip . arg ( path . join ( input , "\\*" ) ) ;
143- zip . arg ( "-r" ) ; // recursive
144- zip . arg ( "-y" ) ; // assume yes on all queries
145- zip . arg ( "-tzip" ) ; // zip format
146- zip . arg ( "-mx9" ) ; // max compression level
164+
165+ if ( tl . getVariable ( "PREVIEW_FAST_UPDATE" ) === "true" )
166+ {
167+ if ( originalVsix !== targetVsix ) { tl . cp ( originalVsix , targetVsix , "-f" ) ; }
168+ zip . arg ( "u" ) ;
169+ zip . arg ( targetVsix ) ; // redirect output to file
170+ zip . arg ( path . join ( tmpPath , "\\*" ) ) ;
171+ zip . arg ( "-r" ) ; // recursive
172+ zip . arg ( "-y" ) ; // assume yes on all queries
173+ zip . arg ( "-tzip" ) ; // zip format
174+ zip . arg ( "-mx9" ) ; // max compression level
175+ zip . arg ( "-bd" ) ; // disable progress indicator
176+
177+ }
178+ else
179+ {
180+ zip . arg ( "a" ) ;
181+ zip . arg ( targetVsix ) ; // redirect output to file
182+ zip . arg ( path . join ( tmpPath , "\\*" ) ) ;
183+ zip . arg ( "-r" ) ; // recursive
184+ zip . arg ( "-y" ) ; // assume yes on all queries
185+ zip . arg ( "-tzip" ) ; // zip format
186+ zip . arg ( "-mx9" ) ; // max compression level
187+ }
147188 zip . execSync ( ) ;
148189 }
149190 else {
150191 const zip = new tr . ToolRunner ( tl . which ( "zip" , true ) ) ;
151- const cwd = tl . cwd ( ) ;
152- tl . cd ( input ) ;
153- zip . arg ( path . join ( cwd , output ) ) ; // redirect output to file
192+ tl . cd ( tmpPath ) ;
193+ zip . arg ( path . join ( cwd , targetVsix ) ) ; // redirect output to file
154194 zip . arg ( "." ) ;
155195 zip . arg ( "-r" ) ; // recursive
156196 zip . arg ( "-9" ) ; // max compression level
157197 zip . execSync ( ) ;
158- tl . cd ( cwd ) ;
159198 }
199+ tl . cd ( cwd ) ;
160200 }
161201
162202 public async endEdit ( ) : Promise < string > {
@@ -193,7 +233,7 @@ export class VSIXEditor {
193233 } )
194234 . then ( ( manifestData : ManifestData ) => {
195235 tl . debug ( `Creating final archive file at ${ this . outputPath } ` ) ;
196- this . createArchive ( manifestData . dirPath , manifestData . outputFileName ) ;
236+ this . createArchive ( this . inputFile , manifestData . dirPath , manifestData . outputFileName ) ;
197237 tl . debug ( "Final archive file created" ) ;
198238 return Promise . resolve ( manifestData . outputFileName ) ;
199239 } ) . catch ( err => { return Promise . reject ( err ) ; } ) ;
0 commit comments