Skip to content

Commit

Permalink
fix: Windows nupkg downloaded twice each time / also keeps downloadin…
Browse files Browse the repository at this point in the history
…g latest release electron-userland#234

Closes electron-userland#234
  • Loading branch information
develar committed Mar 13, 2016
1 parent ebf783c commit 3c90af6
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 28 deletions.
1 change: 0 additions & 1 deletion .idea/runConfigurations/winPackagerTest.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/runConfigurations/winPackagerTest__debug_logging_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 23 additions & 17 deletions src/winPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class WinPackager extends PlatformPackager<any> {
const certificateFile = await this.certFilePromise
const version = this.metadata.version
const installerOutDir = this.computeDistOut(outDir, arch)
const archSuffix = arch === "x64" ? "-x64" : ""
const archSuffix = arch === "x64" ? "" : ("-" + arch)
const options = Object.assign({
name: this.metadata.name,
productName: this.appName,
Expand Down Expand Up @@ -137,28 +137,34 @@ export default class WinPackager extends PlatformPackager<any> {
const nupkgPathOriginal = this.metadata.name + "-" + version + "-full.nupkg"
const nupkgPathWithArch = this.metadata.name + "-" + version + archSuffix + "-full.nupkg"

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

await BluebirdPromise.all([
const promises: Array<Promise<any>> = [
rename(path.join(installerOutDir, "Setup.exe"), installerExePath)
.then(it => this.dispatchArtifactCreated(it)),
rename(path.join(installerOutDir, nupkgPathOriginal), path.join(installerOutDir, nupkgPathWithArch))
.then(it => this.dispatchArtifactCreated(it)),
changeFileNameInTheReleasesFile()
.then(() => {
if (arch === "x64") {
this.dispatchArtifactCreated(releasesFile)
return null
}
else {
return copy(releasesFile, path.join(installerOutDir, "RELEASES-ia32"))
.then(it => this.dispatchArtifactCreated(it))
}
}),
])
]

if (archSuffix === "") {
this.dispatchArtifactCreated(path.join(installerOutDir, nupkgPathOriginal))
this.dispatchArtifactCreated(path.join(installerOutDir, "RELEASES"))
}
else {
promises.push(
rename(path.join(installerOutDir, nupkgPathOriginal), path.join(installerOutDir, nupkgPathWithArch))
.then(it => this.dispatchArtifactCreated(it))
)
promises.push(
changeFileNameInTheReleasesFile()
.then(() => copy(releasesFile, path.join(installerOutDir, "RELEASES-ia32")))
.then(it => this.dispatchArtifactCreated(it))
)
}

await BluebirdPromise.all(promises)
}

private async nsis(options: any, installerFile: string) {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/no-author-email/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Test Application",
"author": "Foo Bar",
"devDependencies": {
"electron-prebuilt": "^0.36.10"
"electron-prebuilt": "^0.37.1"
},
"build": {
"app-bundle-id": "your.id",
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/test-app-one/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"author": "Foo Bar <[email protected]>",
"devDependencies": {
"electron-prebuilt": "^0.36.10"
"electron-prebuilt": "^0.37.1"
},
"build": {
"app-bundle-id": "your.id",
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"start": "electron ."
},
"devDependencies": {
"electron-prebuilt": "^0.36.10"
"electron-prebuilt": "^0.37.1"
}
}
12 changes: 6 additions & 6 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,21 @@ async function checkOsXResult(packager: Packager, artifacts: Array<string>) {
async function checkWindowsResult(packagerOptions: PackagerOptions, artifacts: Array<string>) {
const expected32 = [
"RELEASES-ia32",
"TestApp-1.0.0-full.nupkg",
"TestAppSetup-1.0.0.exe"
"TestAppSetup-1.0.0-ia32.exe",
"TestApp-1.0.0-ia32-full.nupkg",
]
const expected64 = [
"RELEASES",
"TestAppSetup-1.0.0-x64.exe",
"TestApp-1.0.0-x64-full.nupkg"
"TestAppSetup-1.0.0.exe",
"TestApp-1.0.0-full.nupkg",
]
const expected = packagerOptions != null && packagerOptions.arch === "x64" ? expected64 : expected32.concat(expected64)
const filenames = artifacts.map(it => path.basename((it)))
assertThat(filenames.slice().sort()).deepEqual(expected.sort())

let i = filenames.indexOf("RELEASES")
let i = filenames.indexOf("RELEASES-ia32")
if (i !== -1) {
assertThat((await readText(artifacts[i])).indexOf("x64")).not.equal(-1)
assertThat((await readText(artifacts[i])).indexOf("ia32")).not.equal(-1)
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/src/helpers/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const rootDir = path.join(__dirname, "..", "..", "..")
const testPackageDir = path.join(require("os").tmpdir(), "electron_builder_published")
const testNodeModules = path.join(testPackageDir, "node_modules")

const electronVersion = "0.36.10"
const electronVersion = "0.37.1"

BluebirdPromise.all([
deleteOldElectronVersion(),
Expand Down

0 comments on commit 3c90af6

Please sign in to comment.