Skip to content

Commit 3c90af6

Browse files
committed
fix: Windows nupkg downloaded twice each time / also keeps downloading latest release #234
Closes #234
1 parent ebf783c commit 3c90af6

File tree

8 files changed

+42
-28
lines changed

8 files changed

+42
-28
lines changed

.idea/runConfigurations/winPackagerTest.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/winPackagerTest__debug_logging_.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/winPackager.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default class WinPackager extends PlatformPackager<any> {
8686
const certificateFile = await this.certFilePromise
8787
const version = this.metadata.version
8888
const installerOutDir = this.computeDistOut(outDir, arch)
89-
const archSuffix = arch === "x64" ? "-x64" : ""
89+
const archSuffix = arch === "x64" ? "" : ("-" + arch)
9090
const options = Object.assign({
9191
name: this.metadata.name,
9292
productName: this.appName,
@@ -137,28 +137,34 @@ export default class WinPackager extends PlatformPackager<any> {
137137
const nupkgPathOriginal = this.metadata.name + "-" + version + "-full.nupkg"
138138
const nupkgPathWithArch = this.metadata.name + "-" + version + archSuffix + "-full.nupkg"
139139

140-
async function changeFileNameInTheReleasesFile() {
140+
async function changeFileNameInTheReleasesFile(): Promise<void> {
141141
const data = (await readFile(releasesFile, "utf8")).replace(new RegExp(" " + nupkgPathOriginal + " ", "g"), " " + nupkgPathWithArch + " ")
142+
debugger
142143
await writeFile(releasesFile, data)
143144
}
144145

145-
await BluebirdPromise.all([
146+
const promises: Array<Promise<any>> = [
146147
rename(path.join(installerOutDir, "Setup.exe"), installerExePath)
147148
.then(it => this.dispatchArtifactCreated(it)),
148-
rename(path.join(installerOutDir, nupkgPathOriginal), path.join(installerOutDir, nupkgPathWithArch))
149-
.then(it => this.dispatchArtifactCreated(it)),
150-
changeFileNameInTheReleasesFile()
151-
.then(() => {
152-
if (arch === "x64") {
153-
this.dispatchArtifactCreated(releasesFile)
154-
return null
155-
}
156-
else {
157-
return copy(releasesFile, path.join(installerOutDir, "RELEASES-ia32"))
158-
.then(it => this.dispatchArtifactCreated(it))
159-
}
160-
}),
161-
])
149+
]
150+
151+
if (archSuffix === "") {
152+
this.dispatchArtifactCreated(path.join(installerOutDir, nupkgPathOriginal))
153+
this.dispatchArtifactCreated(path.join(installerOutDir, "RELEASES"))
154+
}
155+
else {
156+
promises.push(
157+
rename(path.join(installerOutDir, nupkgPathOriginal), path.join(installerOutDir, nupkgPathWithArch))
158+
.then(it => this.dispatchArtifactCreated(it))
159+
)
160+
promises.push(
161+
changeFileNameInTheReleasesFile()
162+
.then(() => copy(releasesFile, path.join(installerOutDir, "RELEASES-ia32")))
163+
.then(it => this.dispatchArtifactCreated(it))
164+
)
165+
}
166+
167+
await BluebirdPromise.all(promises)
162168
}
163169

164170
private async nsis(options: any, installerFile: string) {

test/fixtures/no-author-email/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Test Application",
66
"author": "Foo Bar",
77
"devDependencies": {
8-
"electron-prebuilt": "^0.36.10"
8+
"electron-prebuilt": "^0.37.1"
99
},
1010
"build": {
1111
"app-bundle-id": "your.id",

test/fixtures/test-app-one/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"author": "Foo Bar <foo@example.com>",
1010
"devDependencies": {
11-
"electron-prebuilt": "^0.36.10"
11+
"electron-prebuilt": "^0.37.1"
1212
},
1313
"build": {
1414
"app-bundle-id": "your.id",

test/fixtures/test-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"start": "electron ."
55
},
66
"devDependencies": {
7-
"electron-prebuilt": "^0.36.10"
7+
"electron-prebuilt": "^0.37.1"
88
}
99
}

test/src/helpers/packTester.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,21 @@ async function checkOsXResult(packager: Packager, artifacts: Array<string>) {
139139
async function checkWindowsResult(packagerOptions: PackagerOptions, artifacts: Array<string>) {
140140
const expected32 = [
141141
"RELEASES-ia32",
142-
"TestApp-1.0.0-full.nupkg",
143-
"TestAppSetup-1.0.0.exe"
142+
"TestAppSetup-1.0.0-ia32.exe",
143+
"TestApp-1.0.0-ia32-full.nupkg",
144144
]
145145
const expected64 = [
146146
"RELEASES",
147-
"TestAppSetup-1.0.0-x64.exe",
148-
"TestApp-1.0.0-x64-full.nupkg"
147+
"TestAppSetup-1.0.0.exe",
148+
"TestApp-1.0.0-full.nupkg",
149149
]
150150
const expected = packagerOptions != null && packagerOptions.arch === "x64" ? expected64 : expected32.concat(expected64)
151151
const filenames = artifacts.map(it => path.basename((it)))
152152
assertThat(filenames.slice().sort()).deepEqual(expected.sort())
153153

154-
let i = filenames.indexOf("RELEASES")
154+
let i = filenames.indexOf("RELEASES-ia32")
155155
if (i !== -1) {
156-
assertThat((await readText(artifacts[i])).indexOf("x64")).not.equal(-1)
156+
assertThat((await readText(artifacts[i])).indexOf("ia32")).not.equal(-1)
157157
}
158158
}
159159

test/src/helpers/runTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const rootDir = path.join(__dirname, "..", "..", "..")
1414
const testPackageDir = path.join(require("os").tmpdir(), "electron_builder_published")
1515
const testNodeModules = path.join(testPackageDir, "node_modules")
1616

17-
const electronVersion = "0.36.10"
17+
const electronVersion = "0.37.1"
1818

1919
BluebirdPromise.all([
2020
deleteOldElectronVersion(),

0 commit comments

Comments
 (0)