Skip to content

Commit

Permalink
fix: Error during signing when running as Windows SYSTEM user
Browse files Browse the repository at this point in the history
Closes #1164
  • Loading branch information
develar committed Jan 25, 2017
1 parent 7c2973d commit 688111e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions packages/electron-builder-util/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { execFile, spawn as _spawn, ChildProcess, SpawnOptions } from "child_process"
import BluebirdPromise from "bluebird-lst-c"
import { homedir } from "os"
import { homedir, tmpdir } from "os"
import * as path from "path"
import { yellow, red } from "chalk"
import _debug from "debug"
Expand Down Expand Up @@ -208,12 +208,17 @@ export function getCacheDirectory(): string {
if (process.platform === "darwin") {
return path.join(homedir(), "Library", "Caches", "electron-builder")
}
else if (process.platform === "win32" && process.env.LOCALAPPDATA != null) {
return path.join(process.env.LOCALAPPDATA, "electron-builder", "cache")
}
else {
return path.join(homedir(), ".cache", "electron-builder")

const localappdata = process.env.LOCALAPPDATA
if (process.platform === "win32" && localappdata != null) {
// https://github.com/electron-userland/electron-builder/issues/1164
if (localappdata.includes("\\Windows\\System32\\") || process.env.USERNAME === "SYSTEM") {
return path.join(tmpdir(), "electron-builder-cache")
}
return path.join(localappdata, "electron-builder", "cache")
}

return path.join(homedir(), ".cache", "electron-builder")
}

// fpm bug - rpm build --description is not escaped, well... decided to replace quite to smart quote
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class NsisTarget extends Target {
private async doBuild(appOutDir: string, arch: Arch) {
log(`Packaging NSIS installer for arch ${Arch[arch]}`)

await copyFile(path.join(await nsisPathPromise, "elevate.exe"), path.join(appOutDir, "resources", "elevate.exe"))
await copyFile(path.join(await nsisPathPromise, "elevate.exe"), path.join(appOutDir, "resources", "elevate.exe"), null, false)

const packager = this.packager
const archiveFile = path.join(this.outDir, `${packager.appInfo.name}-${packager.appInfo.version}-${Arch[arch]}.nsis.7z`)
Expand Down

0 comments on commit 688111e

Please sign in to comment.