@@ -68,7 +68,7 @@ describe("Destructive Command Guard manager", () => {
6868
6969 it ( "rejects untrusted download URLs before opening a destination" , async ( ) => {
7070 await expect ( downloadFile ( "https://example.com/dcg" , path . join ( tempDir , "archive" ) ) ) . rejects . toThrow (
71- "DCG download redirected to an untrusted host" ,
71+ "DCG download URL is not a trusted HTTPS host" ,
7272 )
7373 } )
7474
@@ -81,7 +81,7 @@ describe("Destructive Command Guard manager", () => {
8181 "Too many DCG download redirects" ,
8282 )
8383 expect ( ( ) => resolveTrustedRedirect ( "https://github.com/release" , undefined , 5 ) ) . toThrow (
84- "Too many DCG download redirects " ,
84+ "DCG download redirect is missing a Location header " ,
8585 )
8686 } )
8787
@@ -113,7 +113,14 @@ describe("Destructive Command Guard manager", () => {
113113 const expectedExecutable = process . platform === "win32" ? "powershell" : "unzip"
114114 const expectedArgs =
115115 process . platform === "win32"
116- ? [ "-NoProfile" , "-Command" , "Expand-Archive -Path 'C:\\dcg.zip' -DestinationPath 'C:\\staging' -Force" ]
116+ ? [
117+ "-NoProfile" ,
118+ "-NonInteractive" ,
119+ "-Command" ,
120+ "$archivePath = $args[0]; $destination = $args[1]; Expand-Archive -LiteralPath $archivePath -DestinationPath $destination -Force" ,
121+ "C:\\dcg.zip" ,
122+ "C:\\staging" ,
123+ ]
117124 : [ "-o" , "C:\\dcg.zip" , "-d" , "C:\\staging" ]
118125
119126 expect ( mockSpawn ) . toHaveBeenCalledWith ( expectedExecutable , expectedArgs , {
@@ -136,11 +143,9 @@ describe("Destructive Command Guard manager", () => {
136143
137144 await expect ( extraction ) . resolves . toBeUndefined ( )
138145 expect ( mockSpawn ) . toHaveBeenCalledTimes ( 1 )
139- expect ( mockSpawn ) . toHaveBeenCalledWith (
140- "tar" ,
141- expect . arrayContaining ( [ "-xJf" , "/tmp/dcg.tar.xz" , "-C" , tempDir , "--no-same-owner" ] ) ,
142- expect . objectContaining ( { shell : false } ) ,
143- )
146+ const expectedArgs = [ "-xJf" , "/tmp/dcg.tar.xz" , "-C" , tempDir , "--no-same-owner" ]
147+ if ( process . platform === "linux" ) expectedArgs . push ( "--no-overwrite-dir" )
148+ expect ( mockSpawn ) . toHaveBeenCalledWith ( "tar" , expectedArgs , { shell : false , stdio : [ "ignore" , "pipe" , "pipe" ] } )
144149 } )
145150
146151 it ( "surfaces process failures during extraction" , async ( ) => {
0 commit comments