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

Code before:
    if (options.compression != null) {
      fpmConfiguration.compression = options.compression
    }

    // noinspection JSDeprecatedSymbols
    const depends = options.depends
    if (depends != null) {
      if (Array.isArray(depends)) {
        fpmConfiguration.customDepends = depends
      } else {
        // noinspection SuspiciousTypeOfGuard
        if (typeof depends === "string") {
          fpmConfiguration.customDepends = [depends as string]
        } else {
          throw new Error(`depends must be Array or String, but specified as: ${depends}`)
        }
      }
    }

    if (target === "deb") {
      const recommends = (options as DebOptions).recommends
      if (recommends != null) {
        if (Array.isArray(recommends)) {
          fpmConfiguration.customRecommends = recommends
        } else {
          // noinspection SuspiciousTypeOfGuard
          if (typeof recommends === "string") {
            fpmConfiguration.customRecommends = [recommends as string]
          } else {
            throw new Error(`recommends must be Array or String, but specified as: ${recommends}`)
          }
        }
      }
    }

    use(packager.info.metadata.license, it => args.push("--license", it))
    use(appInfo.buildNumber, it =>
      args.push(
        "--iteration",
        // dashes are not supported for iteration in older versions of fpm
        // https://github.com/jordansissel/fpm/issues/1833
        it.split("-").join("_")
      )
    )

    use(options.fpm, it => args.push(...it))

    args.push(`${appOutDir}/=${installPrefix}/${appInfo.sanitizedProductName}`)
    for (const icon of await this.helper.icons) {
      const extWithDot = path.extname(icon.file)
      const sizeName = extWithDot === ".svg" ? "scalable" : `${icon.size}x${icon.size}`

Review comment (bug):
Since the schema validator will automatically flag incorrect types being passed in, we can simplify this to use `asArray`. I think we should also check a general falsey for `if (recommends) {...}`, as I don't think we should allow an empty string to be passed into customRecommends. What are your thoughts?
```
import { asArray } from "builder-util"

if (target === "deb") {
  const recommends = (options as DebOptions).recommends
  if (recommends) {
      fpmConfiguration.customRecommends = asArray(recommends)
  }
}
```

Code after:
    if (options.compression != null) {
      fpmConfiguration.compression = options.compression
    }

    // noinspection JSDeprecatedSymbols
    const depends = options.depends
    if (depends != null) {
      if (Array.isArray(depends)) {
        fpmConfiguration.customDepends = depends
      } else {
        // noinspection SuspiciousTypeOfGuard
        if (typeof depends === "string") {
          fpmConfiguration.customDepends = [depends as string]
        } else {
          throw new Error(`depends must be Array or String, but specified as: ${depends}`)
        }
      }
    }

    if (target === "deb") {
      const recommends = (options as DebOptions).recommends
      if (recommends) {
        fpmConfiguration.customRecommends = asArray(recommends)
      }
    }

    use(packager.info.metadata.license, it => args.push("--license", it))
    use(appInfo.buildNumber, it =>
      args.push(
        "--iteration",
        // dashes are not supported for iteration in older versions of fpm
        // https://github.com/jordansissel/fpm/issues/1833
        it.split("-").join("_")
      )
    )

    use(options.fpm, it => args.push(...it))

    args.push(`${appOutDir}/=${installPrefix}/${appInfo.sanitizedProductName}`)
    for (const icon of await this.helper.icons) {
      const extWithDot = path.extname(icon.file)
      const sizeName = extWithDot === ".svg" ? "scalable" : `${icon.size}x${icon.size}`
      args.push(`${icon.file}=/usr/share/icons/hicolor/${sizeName}/apps/${packager.executableName}${extWithDot}`)
    }

    const mimeTypeFilePath = await this.helper.mimeTypeFiles
    if (mimeTypeFilePath != null) {
      args.push(`${mimeTypeFilePath}=/usr/share/mime/packages/${packager.executableName}.xml`)
    }

    const desktopFilePath = await this.helper.writeDesktopEntry(this.options)