@@ -9,6 +9,7 @@ import fs from "fs/promises"
99import { Filesystem } from "../util/filesystem"
1010import { Instance } from "../project/instance"
1111import { Flag } from "../flag/flag"
12+ import { Archive } from "../util/archive"
1213
1314export namespace LSPServer {
1415 const log = Log . create ( { service : "lsp.server" } )
@@ -176,7 +177,7 @@ export namespace LSPServer {
176177 const zipPath = path . join ( Global . Path . bin , "vscode-eslint.zip" )
177178 await Bun . file ( zipPath ) . write ( response )
178179
179- await $ `unzip -o -q ${ zipPath } ` . quiet ( ) . cwd ( Global . Path . bin ) . nothrow ( )
180+ await Archive . extractZip ( zipPath , Global . Path . bin )
180181 await fs . rm ( zipPath , { force : true } )
181182
182183 const extractedPath = path . join ( Global . Path . bin , "vscode-eslint-main" )
@@ -438,7 +439,7 @@ export namespace LSPServer {
438439 const zipPath = path . join ( Global . Path . bin , "elixir-ls.zip" )
439440 await Bun . file ( zipPath ) . write ( response )
440441
441- await $ `unzip -o -q ${ zipPath } ` . quiet ( ) . cwd ( Global . Path . bin ) . nothrow ( )
442+ await Archive . extractZip ( zipPath , Global . Path . bin )
442443
443444 await fs . rm ( zipPath , {
444445 force : true ,
@@ -541,7 +542,7 @@ export namespace LSPServer {
541542 await Bun . file ( tempPath ) . write ( downloadResponse )
542543
543544 if ( ext === "zip" ) {
544- await $ `unzip -o -q ${ tempPath } ` . quiet ( ) . cwd ( Global . Path . bin ) . nothrow ( )
545+ await Archive . extractZip ( tempPath , Global . Path . bin )
545546 } else {
546547 await $ `tar -xf ${ tempPath } ` . cwd ( Global . Path . bin ) . nothrow ( )
547548 }
@@ -840,7 +841,7 @@ export namespace LSPServer {
840841 }
841842
842843 if ( zip ) {
843- await $ `unzip -o -q ${ archive } ` . quiet ( ) . cwd ( Global . Path . bin ) . nothrow ( )
844+ await Archive . extractZip ( archive , Global . Path . bin )
844845 }
845846 if ( tar ) {
846847 await $ `tar -xf ${ archive } ` . cwd ( Global . Path . bin ) . nothrow ( )
@@ -1188,14 +1189,21 @@ export namespace LSPServer {
11881189 await fs . mkdir ( installDir , { recursive : true } )
11891190
11901191 if ( ext === "zip" ) {
1191- const ok = await $ `unzip -o -q ${ tempPath } -d ${ installDir } ` . quiet ( ) . catch ( ( error ) => {
1192- log . error ( "Failed to extract lua-language-server archive" , { error } )
1193- } )
1192+ const ok = await Archive . extractZip ( tempPath , installDir )
1193+ . then ( ( ) => true )
1194+ . catch ( ( error ) => {
1195+ log . error ( "Failed to extract lua-language-server archive" , { error } )
1196+ return false
1197+ } )
11941198 if ( ! ok ) return
11951199 } else {
1196- const ok = await $ `tar -xzf ${ tempPath } -C ${ installDir } ` . quiet ( ) . catch ( ( error ) => {
1197- log . error ( "Failed to extract lua-language-server archive" , { error } )
1198- } )
1200+ const ok = await $ `tar -xzf ${ tempPath } -C ${ installDir } `
1201+ . quiet ( )
1202+ . then ( ( ) => true )
1203+ . catch ( ( error ) => {
1204+ log . error ( "Failed to extract lua-language-server archive" , { error } )
1205+ return false
1206+ } )
11991207 if ( ! ok ) return
12001208 }
12011209
@@ -1396,7 +1404,7 @@ export namespace LSPServer {
13961404 const tempPath = path . join ( Global . Path . bin , assetName )
13971405 await Bun . file ( tempPath ) . write ( downloadResponse )
13981406
1399- await $ `unzip -o -q ${ tempPath } ` . cwd ( Global . Path . bin ) . nothrow ( )
1407+ await Archive . extractZip ( tempPath , Global . Path . bin )
14001408 await fs . rm ( tempPath , { force : true } )
14011409
14021410 bin = path . join ( Global . Path . bin , "terraform-ls" + ( platform === "win32" ? ".exe" : "" ) )
@@ -1481,7 +1489,7 @@ export namespace LSPServer {
14811489 await Bun . file ( tempPath ) . write ( downloadResponse )
14821490
14831491 if ( ext === "zip" ) {
1484- await $ `unzip -o -q ${ tempPath } ` . cwd ( Global . Path . bin ) . nothrow ( )
1492+ await Archive . extractZip ( tempPath , Global . Path . bin )
14851493 }
14861494 if ( ext === "tar.gz" ) {
14871495 await $ `tar -xzf ${ tempPath } ` . cwd ( Global . Path . bin ) . nothrow ( )
0 commit comments