@@ -52,18 +52,13 @@ async function nodeDecompress(sourceZip: string, destDir: string, fileCode: stri
5252}
5353
5454export async function compress ( sourceZip : string , files : string [ ] , fileCode ?: string ) {
55- if ( system === "linux" ) {
56- return await linuxZip ( sourceZip , files ) ;
57- }
55+ if ( system === "linux" && haveLinuxZip ( ) ) return await linuxZip ( sourceZip , files ) ;
56+
5857 return await nodeCompress ( sourceZip , files , fileCode ) ;
5958}
6059
6160export async function decompress ( zipPath : string , dest : string , fileCode ?: string ) {
62- if ( system === "linux" ) {
63- if ( haveLinuxUnzip ( ) ) {
64- return await linuxUnzip ( zipPath , dest ) ;
65- }
66- }
61+ if ( system === "linux" && haveLinuxUnzip ( ) ) return await linuxUnzip ( zipPath , dest ) ;
6762 return await nodeDecompress ( zipPath , dest , fileCode ) ;
6863}
6964
@@ -104,6 +99,11 @@ function haveLinuxUnzip() {
10499 return result ?. toString ( "utf-8" ) . toLowerCase ( ) . includes ( "extended help for unzip" ) ;
105100}
106101
102+ function haveLinuxZip ( ) {
103+ const result = child_process . execSync ( "zip -h2" ) ;
104+ return result ?. toString ( "utf-8" ) . toLowerCase ( ) . includes ( "extended help for zip" ) ;
105+ }
106+
107107async function linuxUnzip ( sourceZip : string , destDir : string ) {
108108 return new Promise ( ( resolve , reject ) => {
109109 const process = child_process . spawn ( "unzip" , [ sourceZip , "-d" , destDir ] , {
@@ -119,6 +119,7 @@ async function linuxUnzip(sourceZip: string, destDir: string) {
119119
120120// zip -r a.zip css css_v1 js
121121async function linuxZip ( sourceZip : string , files : string [ ] ) {
122+ console . log ( "DO:" , files ) ;
122123 return new Promise ( ( resolve , reject ) => {
123124 const p = [ "-r" , sourceZip ] ;
124125 p . concat ( files ) ;
0 commit comments