Skip to content

Commit 6270eeb

Browse files
fix: use target platform path separators for asar integrity keys (#1781)
1 parent 7024c67 commit 6270eeb

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/mac.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ export class MacApp extends App implements Plists {
233233
return [...plists, ...(optional as LoadPlistParams[]).filter(item => item)];
234234
}
235235

236-
appRelativePath(p: string) {
237-
return path.relative(this.contentsPath, p);
236+
appRelativePlatformPath(p: string) {
237+
return path.posix.relative(this.contentsPath, p);
238238
}
239239

240240
async updatePlistFiles() {

src/platform.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class App {
138138
if (this.opts.prebuiltAsar) {
139139
await this.copyPrebuiltAsar();
140140
this.asarIntegrity = {
141-
[this.appRelativePath(this.appAsarPath)]: this.getAsarIntegrity(this.appAsarPath),
141+
[this.appRelativePlatformPath(this.appAsarPath)]: this.getAsarIntegrity(this.appAsarPath),
142142
};
143143
} else {
144144
await this.buildApp();
@@ -232,8 +232,12 @@ export class App {
232232
await fs.copy(src, this.appAsarPath, { overwrite: false, errorOnExist: true });
233233
}
234234

235-
appRelativePath(p: string) {
236-
return path.relative(this.stagingPath, p);
235+
appRelativePlatformPath(p: string) {
236+
if (this.opts.platform === 'win32') {
237+
return path.win32.relative(this.stagingPath, p);
238+
}
239+
240+
return path.posix.relative(this.stagingPath, p);
237241
}
238242

239243
async asarApp() {
@@ -247,7 +251,7 @@ export class App {
247251

248252
await asar.createPackageWithOptions(this.originalResourcesAppDir, this.appAsarPath, this.asarOptions);
249253
this.asarIntegrity = {
250-
[this.appRelativePath(this.appAsarPath)]: this.getAsarIntegrity(this.appAsarPath),
254+
[this.appRelativePlatformPath(this.appAsarPath)]: this.getAsarIntegrity(this.appAsarPath),
251255
};
252256
await fs.remove(this.originalResourcesAppDir);
253257

0 commit comments

Comments
 (0)