From 7f8d59cee5ae28699a21fbb5413e5ead0b5f3880 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 26 May 2020 03:57:57 -0500 Subject: [PATCH] fix: sign macOS objects depth-first (close #4932) (#4993) This fix was directly lifted from https://github.com/electron/electron-osx-sign/pull/228 authored by @MarshallOfSound --- packages/app-builder-lib/electron-osx-sign/sign.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/app-builder-lib/electron-osx-sign/sign.js b/packages/app-builder-lib/electron-osx-sign/sign.js index 3b85d83c3c..87da4e57c7 100644 --- a/packages/app-builder-lib/electron-osx-sign/sign.js +++ b/packages/app-builder-lib/electron-osx-sign/sign.js @@ -119,6 +119,17 @@ async function verifySignApplicationAsync (opts) { function signApplicationAsync (opts) { return walkAsync(getAppContentsPath(opts)) .then(async function (childPaths) { + /** + * Sort the child paths by how deep they are in the file tree. Some arcane apple + * logic expects the deeper files to be signed first otherwise strange errors get + * thrown our way + */ + childPaths = childPaths.sort((a, b) => { + const aDepth = a.split(path.sep).length + const bDepth = b.split(path.sep).length + return bDepth - aDepth + }) + function ignoreFilePath (opts, filePath) { if (opts.ignore) { return opts.ignore.some(function (ignore) {