Skip to content

Commit

Permalink
fix: non-English characters confuse rcedit: Unable to load file on wi…
Browse files Browse the repository at this point in the history
…ndows build (from linux)

Closes #384
  • Loading branch information
develar committed Jul 2, 2016
1 parent 922ecdd commit 233fafe
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 22 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/develar.xml

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

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"debug": "^2.2.0",
"deep-assign": "^2.0.0",
"electron-osx-sign-tf": "0.6.0",
"electron-packager-tf": "~7.5.1",
"electron-winstaller-fixed": "~2.11.5",
"electron-packager-tf": "~7.5.2",
"electron-winstaller-fixed": "~2.11.6",
"fs-extra-p": "^1.0.5",
"hosted-git-info": "^2.1.5",
"image-size": "^0.5.0",
Expand Down Expand Up @@ -102,10 +102,10 @@
},
"devDependencies": {
"@types/debug": "0.0.22-alpha",
"@types/mime": "0.0.22-alpha",
"@types/progress": "^1.1.21-alpha",
"@types/semver": "^4.3.20-alpha",
"@types/source-map-support": "^0.2.21-alpha",
"@types/mime": "0.0.25-alpha",
"@types/progress": "^1.1.24-alpha",
"@types/semver": "^4.3.23-alpha",
"@types/source-map-support": "^0.2.24-alpha",
"ava-tf": "^0.15.3",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
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
@@ -1,7 +1,7 @@
{
"private": true,
"name": "TestApp",
"productName": "Test App A/B",
"productName": "Test App ß/W",
"version": "1.1.0",
"homepage": "http://foo.example.com",
"description": "Test Application (test quite \" #378)",
Expand Down
21 changes: 12 additions & 9 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async function checkLinuxResult(projectDir: string, packager: Packager, checkOpt
}

const productFilename = packager.appInfo.productFilename
const expectedContents = expectedLinuxContents.map(it => {
const expectedContents = pathSorter(expectedLinuxContents.map(it => {
if (it === "/opt/TestApp/TestApp") {
return "/opt/" + productFilename + "/" + productFilename
}
Expand All @@ -154,15 +154,15 @@ async function checkLinuxResult(projectDir: string, packager: Packager, checkOpt
else {
return it.replace(new RegExp("/opt/TestApp/", "g"), `/opt/${productFilename}/`)
}
})
}))

// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb", productName), null, 2))
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName), null, 2))

const packageFile = `${projectDir}/${outDirName}/TestApp-${packager.appInfo.version}.deb`
assertThat(await getContents(packageFile, productFilename)).isEqualTo(expectedContents)
assertThat(await getContents(packageFile)).isEqualTo(expectedContents)
if (arch === Arch.ia32) {
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-${packager.appInfo.version}-i386.deb`, productFilename)).isEqualTo(expectedContents)
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-${packager.appInfo.version}-i386.deb`)).isEqualTo(expectedContents)
}

assertThat2(parseDebControl(await exec("dpkg", ["--info", packageFile]))).has.properties({
Expand Down Expand Up @@ -277,14 +277,17 @@ async function checkWindowsResult(packager: Packager, checkOptions: AssertPackOp

// console.log(JSON.stringify(files, null, 2))
const expectedContents = checkOptions == null || checkOptions.expectedContents == null ? expectedWinContents : checkOptions.expectedContents
assertThat(files).isEqualTo(expectedContents.map(it => {
assertThat(files).isEqualTo(pathSorter(expectedContents.map(it => {
if (it === "lib/net45/TestApp.exe") {
return `lib/net45/${encodeURI(appInfo.productFilename)}.exe`
if (appInfo.productFilename === "Test App ßW") {
return `lib/net45/Test%20App%20%C3%9FW.exe`
}
return `lib/net45/${encodeURI(appInfo.productFilename).replace(/%5B/g, '[').replace(/%5D/g, ']')}.exe`
}
else {
return it
}
}))
})))

if (checkOptions == null || checkOptions.expectedContents == null) {
await unZipper.extractFile(fileDescriptors.filter(it => it.path === "TestApp.nuspec")[0], {
Expand All @@ -310,12 +313,12 @@ async function checkWindowsResult(packager: Packager, checkOptions: AssertPackOp
}
}

async function getContents(path: string, productName: string) {
async function getContents(path: string) {
const result = await exec("dpkg", ["--contents", path])
return pathSorter(result
.split("\n")
.map(it => it.length === 0 ? null : it.substring(it.indexOf(".") + 1))
.filter(it => it != null && !(it.startsWith(`/opt/${productName}/locales/`) || it.startsWith(`/opt/${productName}/libgcrypt`)))
.filter(it => it != null && !(it.includes(`/locales/`) || it.includes(`/libgcrypt`)))
)
}

Expand Down
8 changes: 4 additions & 4 deletions test/src/macPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ function createTargetTest(target: Array<string>, expectedContents: Array<string>
})
}

test.ifOsx("only dmg", createTargetTest(["dmg"], ["Test App AB-1.1.0.dmg"]))
test.ifOsx("only zip", createTargetTest(["zip"], ["Test App AB-1.1.0-mac.zip"]))
test.ifOsx("only dmg", createTargetTest(["dmg"], ["Test App ßW-1.1.0.dmg"]))
test.ifOsx("only zip", createTargetTest(["zip"], ["Test App ßW-1.1.0-mac.zip"]))
test.ifOsx("invalid target", (t: any) => t.throws(createTargetTest(["ttt"], [])(), "Unknown target: ttt"))

test.ifOsx("mas", createTargetTest(["mas"], ["Test App AB-1.1.0.pkg"]))
test.ifOsx("mas and 7z", createTargetTest(["mas", "7z"], ["Test App AB-1.1.0-mac.7z", "Test App AB-1.1.0.pkg"]))
test.ifOsx("mas", createTargetTest(["mas"], ["Test App ßW-1.1.0.pkg"]))
test.ifOsx("mas and 7z", createTargetTest(["mas", "7z"], ["Test App ßW-1.1.0-mac.7z", "Test App ßW-1.1.0.pkg"]))

test.ifOsx("custom mas", () => {
let platformPackager: CheckingOsXPackager = null
Expand Down
2 changes: 1 addition & 1 deletion test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"src/ArtifactPublisherTest.ts",
"src/BuildTest.ts",
"src/CodeSignTest.ts",
"src/RepoSlugTest.ts",
"src/globTest.ts",
"src/helpers/avaEx.ts",
"src/helpers/codeSignData.ts",
Expand All @@ -76,7 +77,6 @@
"src/httpRequestTest.ts",
"src/linuxPackagerTest.ts",
"src/macPackagerTest.ts",
"src/RepoSlugTest.ts",
"src/winPackagerTest.ts"
]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@
"src/packager.ts",
"src/platformPackager.ts",
"src/repositoryInfo.ts",
"src/targets/LinuxTargetHelper.ts",
"src/targets/appImage.ts",
"src/targets/archive.ts",
"src/targets/dmg.ts",
"src/targets/fpm.ts",
"src/targets/LinuxTargetHelper.ts",
"src/targets/nsis.ts",
"src/targets/squirrelWindows.ts",
"src/targets/targetFactory.ts",
Expand Down

0 comments on commit 233fafe

Please sign in to comment.