@@ -14,17 +14,27 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
1414const assertVolumeIconMatchesSnapshot = ( t , dmgPath ) => {
1515 // Mount the DMG and extract the volume icon
1616 const existingVolumes = new Set ( fs . readdirSync ( '/Volumes' ) ) ;
17- spawnSync ( 'hdiutil' , [ 'mount' , dmgPath ] ) ;
17+ const mountResult = spawnSync ( 'hdiutil' , [ 'mount' , dmgPath ] , { timeout : 10000 } ) ;
18+
19+ if ( mountResult . status !== 0 ) {
20+ throw new Error ( `Failed to mount DMG: ${ mountResult . stderr ?. toString ( ) } ` ) ;
21+ }
22+
1823 const volumes = new Set ( fs . readdirSync ( '/Volumes' ) ) ;
1924 const mountLocation = [ ...volumes ] . find ( x => ! existingVolumes . has ( x ) ) ;
2025 t . truthy ( mountLocation ) ;
2126 const dmgIconPath = path . join ( '/Volumes' , mountLocation , '.VolumeIcon.icns' )
2227 const dirPath = path . dirname ( dmgPath ) ;
2328 const iconPath = path . join ( dirPath , 'VolumeIcon.icns' ) ;
2429 fs . copyFileSync ( dmgIconPath , iconPath ) ;
25- spawnSync ( 'hdiutil' , [ 'unmount' , path . join ( '/Volumes' , mountLocation ) ] ) ;
30+ const unmountResult = spawnSync ( 'hdiutil' , [ 'unmount' , '-force' , path . join ( '/Volumes' , mountLocation ) ] , { timeout : 10000 } ) ;
31+
32+ if ( unmountResult . status !== 0 ) {
33+ throw new Error ( `Failed to unmount ${ mountLocation } : ${ unmountResult . stderr ?. toString ( ) } ` ) ;
34+ }
35+
2636 const pngPath = path . join ( dirPath , 'VolumeIcon.png' ) ;
27- spawnSync ( 'sips' , [ '-s' , 'format' , 'png' , iconPath , '--out' , pngPath ] ) ;
37+ spawnSync ( 'sips' , [ '-s' , 'format' , 'png' , iconPath , '--out' , pngPath ] , { timeout : 10000 } ) ;
2838
2939 // Compare the extracted icon to the snapshot
3040 const image = fs . readFileSync ( pngPath ) ;
0 commit comments