1- /*---------------------------------------------------------------------------------------------
2- * Copyright (c) Microsoft Corporation. All rights reserved.
3- * Licensed under the MIT License. See License.txt in the project root for license information.
4- *--------------------------------------------------------------------------------------------*/
5-
61import * as nls from "vs/nls" ;
7- import * as vszip from "vszip " ;
2+ import * as vszip from "vs/base/node/zip " ;
83import * as fs from "fs" ;
94import * as path from "path" ;
105import * as tarStream from "tar-stream" ;
116import { promisify } from "util" ;
127import { CancellationToken } from "vs/base/common/cancellation" ;
138import { mkdirp } from "vs/base/node/pfs" ;
149
10+ // We will be overriding these, so keep a reference to the original.
11+ const vszipExtract = vszip . extract ;
12+ const vszipBuffer = vszip . buffer ;
13+
1514export interface IExtractOptions {
1615 overwrite ?: boolean ;
1716
@@ -29,8 +28,8 @@ export interface IFile {
2928}
3029
3130/**
32- * Override the standard VS Code behavior for zipping
33- * extensions to use the TAR format instead of ZIP.
31+ * Override the standard VS Code behavior for zipping extensions to use the TAR
32+ * format instead of ZIP.
3433 */
3534export const zip = ( tarPath : string , files : IFile [ ] ) : Promise < string > => {
3635 return new Promise < string > ( ( c , e ) : void => {
@@ -63,10 +62,9 @@ export const zip = (tarPath: string, files: IFile[]): Promise<string> => {
6362} ;
6463
6564/**
66- * Override the standard VS Code behavior for extracting
67- * archives, to first attempt to process the archive as a TAR
68- * and then fallback on the original implementation, for processing
69- * ZIPs.
65+ * Override the standard VS Code behavior for extracting archives to first
66+ * attempt to process the archive as a TAR and then fall back to the original
67+ * implementation for processing ZIPs.
7068 */
7169export const extract = ( archivePath : string , extractPath : string , options : IExtractOptions = { } , token : CancellationToken ) : Promise < void > => {
7270 return new Promise < void > ( ( c , e ) : void => {
@@ -76,15 +74,15 @@ export const extract = (archivePath: string, extractPath: string, options: IExtr
7674
7775 return ;
7876 }
79- vszip . extract ( archivePath , extractPath , options , token ) . then ( c ) . catch ( e ) ;
77+ vszipExtract ( archivePath , extractPath , options , token ) . then ( c ) . catch ( e ) ;
8078 } ) ;
8179 } ) ;
8280} ;
8381
8482/**
85- * Override the standard VS Code behavior for buffering
86- * archives, to first process the Buffer as a TAR and then
87- * fallback on the original implementation, for processing ZIPs.
83+ * Override the standard VS Code behavior for buffering archives to first
84+ * process the Buffer as a TAR and then fall back to the original
85+ * implementation for processing ZIPs.
8886 */
8987export const buffer = ( targetPath : string , filePath : string ) : Promise < Buffer > => {
9088 return new Promise < Buffer > ( ( c , e ) : void => {
@@ -104,16 +102,16 @@ export const buffer = (targetPath: string, filePath: string): Promise<Buffer> =>
104102
105103 return ;
106104 }
107- vszip . buffer ( targetPath , filePath ) . then ( c ) . catch ( e ) ;
105+ vszipBuffer ( targetPath , filePath ) . then ( c ) . catch ( e ) ;
108106 } ) ;
109107 } ) ;
110108} ;
111109
112110/**
113- * Override the standard VS Code behavior for extracting assets
114- * from archive Buffers to use the TAR format instead of ZIP.
111+ * Override the standard VS Code behavior for extracting assets from archive
112+ * Buffers to use the TAR format instead of ZIP.
115113 */
116- export const extractAssets = ( tarPath : string , match : RegExp , callback : ( path : string , data : Buffer ) => void ) : Promise < void > => {
114+ const extractAssets = ( tarPath : string , match : RegExp , callback : ( path : string , data : Buffer ) => void ) : Promise < void > => {
117115 return new Promise < void > ( async ( c , e ) : Promise < void > => {
118116 try {
119117 const buffer = await promisify ( fs . readFile ) ( tarPath ) ;
@@ -217,3 +215,9 @@ const extractTar = (tarPath: string, targetPath: string, options: IExtractOption
217215 }
218216 } ) ;
219217} ;
218+
219+ // Override original functionality so we can use tar instead of zip.
220+ const target = vszip as typeof vszip ;
221+ target . zip = zip ;
222+ target . extract = extract ;
223+ target . buffer = buffer ;
0 commit comments