Skip to content

Commit

Permalink
fix: win ia32 out dir name — unexpanded $arch
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed May 13, 2016
1 parent 079989a commit 8d9b952
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"bugs": "https://github.com/electron-userland/electron-builder/issues",
"homepage": "https://github.com/electron-userland/electron-builder",
"dependencies": {
"7zip-bin": "^1.0.0",
"7zip-bin": "^1.0.5",
"asar": "^0.11.0",
"bluebird": "^3.3.5",
"chalk": "^1.1.3",
Expand Down
20 changes: 13 additions & 7 deletions src/fpmDownload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { statOrNull, spawn, debug, debug7z } from "./util"
import { writeFile, rename, remove } from "fs-extra-p"
import { writeFile, rename, remove, stat, emptyDir } from "fs-extra-p"
import { download } from "./httpRequest"
import { path7za } from "7zip-bin"
import * as path from "path"
Expand Down Expand Up @@ -41,25 +41,31 @@ async function doDownloadFpm(version: string, osAndArch: string): Promise<string
const cacheDir = path.join(homedir(), ".cache", "fpm")
const fpmDir = path.join(cacheDir, dirName)

const stat = await statOrNull(fpmDir)
if (stat != null && stat.isDirectory()) {
const fpmDirStat = await statOrNull(fpmDir)
if (fpmDirStat != null && fpmDirStat.isDirectory()) {
debug(`Found existing fpm ${fpmDir}`)
return path.join(fpmDir, "fpm")
}

// 7z cannot be extracted from the input stream, temp file is required
const tempName = getTempName()
const archiveName = path.join(cacheDir, tempName + ".7z")
debug(`Download fpm from ${url} to ${archiveName}`)
await download(url, archiveName)
const archiveName = path.join(cacheDir, `${tempName}.7z`)
const tempUnpackDir = path.join(cacheDir, tempName)
const args = ["x", archiveName, "-o" + tempName, "-bd"]
debug(`Download fpm from ${url} to ${archiveName}`)
await BluebirdPromise.all<any>([download(url, archiveName), emptyDir(tempUnpackDir)])

if (debug.enabled && (!(await stat(archiveName)).isFile())) {
throw new Error(`${archiveName} was not downloaded correctly`)
}

const args = ["x", archiveName, "-o" + tempUnpackDir, "-bd"]
if (debug7z.enabled) {
args.push("-bb3")
}
else if (!debug.enabled) {
args.push("-bb0")
}

await spawn(path7za, args, {
cwd: cacheDir,
stdio: ["ignore", debug.enabled ? "inherit" : "ignore", "inherit"],
Expand Down
2 changes: 1 addition & 1 deletion src/winPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function isIco(buffer: Buffer): boolean {
}

export function computeDistOut(outDir: string, arch: string): string {
return path.join(outDir, "win" + (arch === "x64" ? "" : "-arch"))
return path.join(outDir, `win${arch === "x64" ? "" : `-${arch}` }`)
}

function checkConflictingOptions(options: any) {
Expand Down
15 changes: 13 additions & 2 deletions test/src/winPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@ import ElectronPackagerOptions = ElectronPackager.ElectronPackagerOptions
//noinspection JSUnusedLocalSymbols
const __awaiter = require("out/awaiter")

test.ifNotCiOsx("win", () => assertPack("test-app-one", signed(platform(Platform.WINDOWS)),
test.ifNotCiOsx("win", () => assertPack("test-app-one", signed({
platform: [Platform.WINDOWS],
arch: "all",
}),
{
tempDirCreated: process.env.TEST_DELTA ? it => modifyPackageJson(it, data => {
data.build.win = {
remoteReleases: "https://github.com/develar/__test-app-releases",
}
}) : null
}) : null,
expectedArtifacts: [
"RELEASES",
"RELEASES",
"TestApp Setup 1.1.0-ia32.exe",
"TestApp Setup 1.1.0.exe",
"TestApp-1.1.0-full.nupkg",
"TestApp-1.1.0-full.nupkg"
],
}
))

Expand Down

0 comments on commit 8d9b952

Please sign in to comment.