Skip to content

Commit

Permalink
rename and simplify pattern logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaietta committed Dec 6, 2024
1 parent 833d49b commit ae6545b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions packages/app-builder-lib/src/targets/nsis/NsisTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ export class NsisTarget extends Target {
NsisTargetOptions.resolve(this.options)
}

protected buildUniversalInstaller() {
get shouldBuildUniversalInstaller() {
const buildSeparateInstallers = this.options.buildUniversalInstaller === false
return !buildSeparateInstallers
}

build(appOutDir: string, arch: Arch) {
this.archs.set(arch, appOutDir)
if (!this.buildUniversalInstaller()) {
if (!this.shouldBuildUniversalInstaller) {
return this.buildInstaller(new Map<Arch, string>().set(arch, appOutDir))
}
return Promise.resolve()
Expand Down Expand Up @@ -139,19 +139,18 @@ export class NsisTarget extends Target {
}

protected installerFilenamePattern(primaryArch?: Arch | null, defaultArch?: string): string {
if (!this.buildUniversalInstaller()) {
return "${productName} " + (this.isPortable ? "" : "Setup ") + "${version}" + (primaryArch != null ? getArchSuffix(primaryArch, defaultArch) : "") + ".${ext}"
}
// tslint:disable:no-invalid-template-strings
return "${productName} " + (this.isPortable ? "" : "Setup ") + "${version}.${ext}"
const setupText = this.isPortable ? "" : "Setup "
const archSuffix = !this.shouldBuildUniversalInstaller && primaryArch != null ? getArchSuffix(primaryArch, defaultArch) : ""

return "${productName} " + setupText + "${version}" + archSuffix + ".${ext}";

Check warning on line 145 in packages/app-builder-lib/src/targets/nsis/NsisTarget.ts

View workflow job for this annotation

GitHub Actions / test-linux (ArtifactPublisherTest,BuildTest,ExtraBuildTest,RepoSlugTest,binDownloadTest,configura...

Delete `;`

Check warning on line 145 in packages/app-builder-lib/src/targets/nsis/NsisTarget.ts

View workflow job for this annotation

GitHub Actions / test-linux (snapTest,debTest,fpmTest,protonTest)

Delete `;`
}

private get isPortable(): boolean {
return this.name === "portable"
}

async finishBuild(): Promise<any> {
if (!this.buildUniversalInstaller()) {
if (!this.shouldBuildUniversalInstaller) {
return this.packageHelper.finishBuild()
}
try {
Expand Down Expand Up @@ -375,7 +374,7 @@ export class NsisTarget extends Target {
protected generateGitHubInstallerName(primaryArch: Arch | null, defaultArch: string | undefined): string {
const appInfo = this.packager.appInfo
const classifier = appInfo.name.toLowerCase() === appInfo.name ? "setup-" : "Setup-"
const archSuffix = !this.buildUniversalInstaller() && primaryArch != null ? getArchSuffix(primaryArch, defaultArch) : ""
const archSuffix = !this.shouldBuildUniversalInstaller && primaryArch != null ? getArchSuffix(primaryArch, defaultArch) : ""
return `${appInfo.name}-${this.isPortable ? "" : classifier}${appInfo.version}${archSuffix}.exe`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class WebInstallerTarget extends NsisTarget {
defines.APP_PACKAGE_URL = appPackageUrl
}

protected buildUniversalInstaller(): boolean {
get shouldBuildUniversalInstaller() {
if (this.options.buildUniversalInstaller === false) {
log.warn({ buildUniversalInstaller: true }, "only universal builds are supported for nsis-web installers, overriding setting")
}
Expand Down

0 comments on commit ae6545b

Please sign in to comment.