Repository: electron-userland/electron-builder
File: packages/app-builder-lib/src/macPackager.ts (TypeScript)

Code before:
    let identity = null
    for (const certificateType of certificateTypes) {
      identity = await findIdentity(certificateType, qualifier, keychainFile)
      if (identity != null) {
        break
      }
    }

    if (identity == null) {
      if (!isMas && !isDevelopment && explicitType !== "distribution") {
        identity = await findIdentity("Mac Developer", qualifier, keychainFile)
        if (identity != null) {
          log.warn("Mac Developer is used to sign app — it is only for development and testing, not for production")
        }
      }

      if (qualifier === "-") {
        identity = new Identity("-", undefined)
      }

      if (!options.sign && identity == null) {
        await reportError(isMas, certificateTypes, qualifier, keychainFile, this.forceCodeSigning, fallBackToAdhoc)
        if (fallBackToAdhoc) {
          identity = new Identity("-", undefined)
        } else {
          return false
        }
      }
    }

    if (!isMacOsHighSierra()) {
      throw new InvalidConfigurationError("macOS High Sierra 10.13.6 is required to sign")
    }

    let filter = options.signIgnore
    if (Array.isArray(filter)) {
      if (filter.length == 0) {
        filter = null
      }
    } else if (filter != null) {
      filter = filter.length === 0 ? null : [filter]
    }

    const filterRe = filter == null ? null : filter.map(it => new RegExp(it))

    let binaries = options.binaries || undefined
    if (binaries) {
      // Accept absolute paths for external binaries, else resolve relative paths from the artifact's app Contents path.
      binaries = await Promise.all(
        binaries.map(async destination => {
          if (await statOrNull(destination)) {

Review comment (suggestion):
This part seems a little messy as I'm generally averse to nesting logic when not necessary and I'm seeing `reportError` still having a `throw new Error()`, so the `fallBackToAdhoc` would never be executed.  Maybe this would work? 
```
const noIdentity = !options.sign && identity == null
if (qualifier === "-" || (noIdentity && fallBackToAdhoc)) {
    identity = new Identity("-", undefined)
} else if (noIdentity) {
    await reportError(isMas, certificateTypes, qualifier, keychainFile, this.forceCodeSigning)
    return false
}
```

Code after:
    let identity = null
    for (const certificateType of certificateTypes) {
      identity = await findIdentity(certificateType, qualifier, keychainFile)
      if (identity != null) {
        break
      }
    }

    if (identity == null) {
      if (!isMas && !isDevelopment && explicitType !== "distribution") {
        identity = await findIdentity("Mac Developer", qualifier, keychainFile)
        if (identity != null) {
          log.warn("Mac Developer is used to sign app — it is only for development and testing, not for production")
        }
      }

      const noIdentity = !options.sign && identity == null
      if (qualifier === "-") {
        identity = new Identity("-", undefined)
      } else if (noIdentity && fallBackToAdhoc) {
        log.warn(null, "falling back to ad-hoc signature for macOS application code signing")
        identity = new Identity("-", undefined)
      } else if (noIdentity) {
        await reportError(isMas, certificateTypes, qualifier, keychainFile, this.forceCodeSigning)
        return false
      }
    }

    if (!isMacOsHighSierra()) {
      throw new InvalidConfigurationError("macOS High Sierra 10.13.6 is required to sign")
    }

    let filter = options.signIgnore
    if (Array.isArray(filter)) {
      if (filter.length == 0) {
        filter = null
      }
    } else if (filter != null) {
      filter = filter.length === 0 ? null : [filter]
    }

    const filterRe = filter == null ? null : filter.map(it => new RegExp(it))

    let binaries = options.binaries || undefined
    if (binaries) {
      // Accept absolute paths for external binaries, else resolve relative paths from the artifact's app Contents path.
      binaries = await Promise.all(
        binaries.map(async destination => {
          if (await statOrNull(destination)) {
            return destination
          }