From 6270eeba527a51b944c55fcd16b03f773c609404 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 12 Nov 2024 17:00:57 -0500 Subject: [PATCH] fix: use target platform path separators for asar integrity keys (#1781) --- src/mac.ts | 4 ++-- src/platform.ts | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mac.ts b/src/mac.ts index ae5fd980..00b425d7 100644 --- a/src/mac.ts +++ b/src/mac.ts @@ -233,8 +233,8 @@ export class MacApp extends App implements Plists { return [...plists, ...(optional as LoadPlistParams[]).filter(item => item)]; } - appRelativePath(p: string) { - return path.relative(this.contentsPath, p); + appRelativePlatformPath(p: string) { + return path.posix.relative(this.contentsPath, p); } async updatePlistFiles() { diff --git a/src/platform.ts b/src/platform.ts index ee205da6..d4c663f8 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -138,7 +138,7 @@ export class App { if (this.opts.prebuiltAsar) { await this.copyPrebuiltAsar(); this.asarIntegrity = { - [this.appRelativePath(this.appAsarPath)]: this.getAsarIntegrity(this.appAsarPath), + [this.appRelativePlatformPath(this.appAsarPath)]: this.getAsarIntegrity(this.appAsarPath), }; } else { await this.buildApp(); @@ -232,8 +232,12 @@ export class App { await fs.copy(src, this.appAsarPath, { overwrite: false, errorOnExist: true }); } - appRelativePath(p: string) { - return path.relative(this.stagingPath, p); + appRelativePlatformPath(p: string) { + if (this.opts.platform === 'win32') { + return path.win32.relative(this.stagingPath, p); + } + + return path.posix.relative(this.stagingPath, p); } async asarApp() { @@ -247,7 +251,7 @@ export class App { await asar.createPackageWithOptions(this.originalResourcesAppDir, this.appAsarPath, this.asarOptions); this.asarIntegrity = { - [this.appRelativePath(this.appAsarPath)]: this.getAsarIntegrity(this.appAsarPath), + [this.appRelativePlatformPath(this.appAsarPath)]: this.getAsarIntegrity(this.appAsarPath), }; await fs.remove(this.originalResourcesAppDir);