Skip to content

Commit

Permalink
fix: Do not pack "elevate.exe" when not needed
Browse files Browse the repository at this point in the history
Close #1620
  • Loading branch information
MariaDima committed Jun 5, 2017
1 parent 9014d74 commit 7e9cdb9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
11 changes: 7 additions & 4 deletions packages/electron-builder/src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ export class NsisTarget extends Target {

/** @private */
async buildAppPackage(appOutDir: string, arch: Arch) {
await BluebirdPromise.all([
copyFile(path.join(await nsisPathPromise, "elevate.exe"), path.join(appOutDir, "resources", "elevate.exe"), null, false),
copyFile(path.join(await getSignVendorPath(), "windows-10", Arch[arch], "signtool.exe"), path.join(appOutDir, "resources", "signtool.exe"), null, false),
])
var filesToCopy = [];
if (this.options.allowElevation === undefined || this.options.allowElevation) {
filesToCopy.push(copyFile(path.join(await nsisPathPromise, "elevate.exe"), path.join(appOutDir, "resources", "elevate.exe"), null, false));
}
filesToCopy.push(copyFile(path.join(await getSignVendorPath(), "windows-10", Arch[arch], "signtool.exe"), path.join(appOutDir, "resources", "signtool.exe"), null, false));

await BluebirdPromise.all(filesToCopy)

const packager = this.packager
const format = this.options.useZip ? "zip" : "7z"
Expand Down
9 changes: 8 additions & 1 deletion test/src/helpers/winHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ import { assertThat } from "./fileAssert"
import { PackedContext } from "./packTester"
import { diff, WineManager } from "./wine"

export async function expectUpdateMetadata(context: PackedContext, arch: Arch = Arch.ia32, requireCodeSign: boolean = false): Promise<void> {
export async function expectUpdateMetadata(context: PackedContext, arch: Arch = Arch.ia32, requireCodeSign: boolean = false, allowElevation: boolean = true): Promise<void> {
const data = safeLoad(await readFile(path.join(context.getResources(Platform.WINDOWS, arch), "app-update.yml"), "utf-8"))

if (allowElevation) {
await assertThat(path.join(context.getResources(Platform.WINDOWS, arch), "elevate.exe")).isFile()
} else {
await assertThat(path.join(context.getResources(Platform.WINDOWS, arch), "elevate.exe")).doesNotExist()
}

if (requireCodeSign && process.env.CSC_KEY_PASSWORD != null) {
expect(data.publisherName).toEqual(["Developer ID Installer: Vladimir Krivosheev (X8C9Z9L4HW)"])
delete data.publisherName
Expand Down
3 changes: 2 additions & 1 deletion test/src/windows/oneClickInstallerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ test("one-click", app({
},
nsis: {
deleteAppDataOnUninstall: true,
allowElevation: false
},
}
}, {
signed: true,
packed: async (context) => {
await doTest(context.outDir, true)
await expectUpdateMetadata(context, Arch.ia32, true)
await expectUpdateMetadata(context, Arch.ia32, true, false)
}
}))

Expand Down

0 comments on commit 7e9cdb9

Please sign in to comment.