@@ -12,7 +12,7 @@ import * as path from "path"
1212import { TmpDir } from "temp-file"
1313import { addLicenseToDmg } from "./dmgLicense"
1414import { attachAndExecute , computeBackground , detach , getDmgVendorPath } from "./dmgUtil"
15- import { hdiUtil } from "./hdiuil"
15+ import { hdiUtil , hdiutilTransientExitCodes } from "./hdiuil"
1616
1717export class DmgTarget extends Target {
1818 readonly options : DmgOptions = this . packager . config . dmg || Object . create ( null )
@@ -197,20 +197,27 @@ export class DmgTarget extends Target {
197197}
198198
199199async function createStageDmg ( tempDmg : string , appPath : string , volumeName : string ) {
200- //noinspection SpellCheckingInspection
201- const imageArgs = addLogLevel ( [ "create" , "-srcfolder" , appPath , "-volname" , volumeName , "-anyowners" , "-nospotlight" , "-format" , "UDRW" ] )
200+ const createArgs = [ "create" , "-srcfolder" , appPath , "-volname" , volumeName , "-anyowners" , "-nospotlight" , "-format" , "UDRW" ]
201+ const imageArgs = addLogLevel ( createArgs )
202202 if ( log . isDebugEnabled ) {
203203 imageArgs . push ( "-debug" )
204204 }
205205
206206 imageArgs . push ( "-fs" , "APFS" )
207207 imageArgs . push ( tempDmg )
208- await hdiUtil ( imageArgs )
208+ await hdiUtil ( imageArgs ) . catch ( async e => {
209+ if ( hdiutilTransientExitCodes . has ( e . code ) ) {
210+ // Delay then create, then retry with verbose output
211+ await new Promise ( resolve => setTimeout ( resolve , 3000 ) )
212+ return hdiUtil ( addLogLevel ( createArgs , true ) )
213+ }
214+ throw e
215+ } )
209216 return tempDmg
210217}
211218
212- function addLogLevel ( args : Array < string > ) : Array < string > {
213- args . push ( process . env . DEBUG_DMG === "true" ? "-verbose" : "-quiet" )
219+ function addLogLevel ( args : Array < string > , isVerbose = process . env . DEBUG_DMG === "true" ) : Array < string > {
220+ args . push ( isVerbose ? "-verbose" : "-quiet" )
214221 return args
215222}
216223
0 commit comments