Repository: electron-userland/electron-builder
File: packages/electron-builder-squirrel-windows/src/SquirrelWindowsTarget.ts (TypeScript)

Code before:

    const setupFile = packager.expandArtifactNamePattern(this.options, "exe", arch, "${productName} Setup ${version}.${ext}")
    const installerOutDir = path.join(this.outDir, `squirrel-windows${getArchSuffix(arch)}`)
    const artifactPath = path.join(installerOutDir, setupFile)

    await packager.info.callArtifactBuildStarted({
      targetPresentableName: "Squirrel.Windows",
      file: artifactPath,
      arch,
    })

    if (arch === Arch.ia32) {
      log.warn("For windows consider only distributing 64-bit or use nsis target, see https://github.com/electron-userland/electron-builder/issues/359#issuecomment-214851130")
    }

    this.appDirectory = appOutDir
    this.outputDirectory = installerOutDir
    const distOptions = await this.computeEffectiveDistOptions()

    distOptions.vendorDirectory = await this.prepareSignedVendorDirectory()
    this.select7zipArch(distOptions.vendorDirectory, arch)
    distOptions.fixUpPaths = true
    distOptions.setupExe = setupFile
    if (this.options.msi) {
      distOptions.setupMsi = setupFile.replace(".exe", ".msi")
    }
    await createWindowsInstaller(distOptions)

    await packager.signAndEditResources(artifactPath, arch, installerOutDir)
    if (this.options.msi && process.platform === "win32") {
      await packager.sign(artifactPath.replace(".exe", ".msi"))
    }

    await packager.info.callArtifactBuildCompleted({
      file: artifactPath,
      target: this,
      arch,
      safeArtifactName: `${sanitizedName}-Setup-${version}${getArchSuffix(arch)}.exe`,
      packager: this.packager,
    })

    if (this.options.msi) {
      await packager.info.callArtifactBuildCompleted({
        file: artifactPath.replace(".exe", ".msi"),
        target: this,
        arch,
        safeArtifactName: `${sanitizedName}-Setup-${version}${getArchSuffix(arch)}.msi`,
        packager: this.packager,
      })
    }


Review comment (suggestion):
These all seem like something we should move into `this.computeEffectiveDistOptions({ setupFile, arch, setupMsi })`

Code after:
    const setupFile = packager.expandArtifactNamePattern(this.options, "exe", arch, "${productName} Setup ${version}.${ext}")
    const installerOutDir = path.join(this.outDir, `squirrel-windows${getArchSuffix(arch)}`)
    const artifactPath = path.join(installerOutDir, setupFile)
    const msiArtifactPath = path.join(installerOutDir, packager.expandArtifactNamePattern(this.options, "msi", arch, "${productName} Setup ${version}.${ext}"))

    await packager.info.callArtifactBuildStarted({
      targetPresentableName: "Squirrel.Windows",
      file: artifactPath,
      arch,
    })

    const distOptions = await this.computeEffectiveDistOptions(appOutDir, installerOutDir, setupFile)
    await createWindowsInstaller(distOptions)

    await packager.signAndEditResources(artifactPath, arch, installerOutDir)
    if (this.options.msi) {
      await packager.sign(msiArtifactPath)
    }

    const safeArtifactName = (ext: string) => `${sanitizedName}-Setup-${version}${getArchSuffix(arch)}.${ext}`

    await packager.info.callArtifactBuildCompleted({
      file: artifactPath,
      target: this,
      arch,
      safeArtifactName: safeArtifactName("exe"),
      packager: this.packager,
    })

    if (this.options.msi) {
      await packager.info.callArtifactBuildCompleted({
        file: msiArtifactPath,
        target: this,
        arch,
        safeArtifactName: safeArtifactName("msi"),
        packager: this.packager,
      })
    }

    const packagePrefix = `${this.appName}-${convertVersion(version)}-`
    packager.info.dispatchArtifactCreated({
      file: path.join(installerOutDir, `${packagePrefix}full.nupkg`),
      target: this,
      arch,
      packager,
    })
    if (distOptions.remoteReleases != null) {
      packager.info.dispatchArtifactCreated({
        file: path.join(installerOutDir, `${packagePrefix}delta.nupkg`),
        target: this,
        arch,