electron / osx-sign

Codesign Electron macOS apps
BSD 2-Clause "Simplified" License
565 stars 96 forks source link

fix: Sort file name length if same directory #255

Closed aquacash5 closed 2 years ago

aquacash5 commented 2 years ago

I just had this issue where my app would not sign. I am adding a couple of extra binaries to the Contents/MacOS directory. The file names happened to be longer than the application name. I spent two days trying to figure out why these files wouldn't sign.

This was my solution and it seems to work well.

MarshallOfSound commented 2 years ago

Can you please rebase this for CI fixes 👍

aquacash5 commented 2 years ago

Done!

I also have added another level of sorting. I recently ran into the same issue when the file names were the same length.

aquacash5 commented 2 years ago

I am going to close this PR. After running into this issue again, I believe the true problem is that the electron binary has to be signed last. This isn't a problem for projects that only consist of the one electron binary, but our project includes a series of side binaries that must be signed first.

My current fix is to modify the sort function (using patch-package) as follows:

childPaths = childPaths.sort((a, b) => {
+ if (a.endsWith('executable-name')) return 1
+ if (b.endsWith('executable-name')) return -1
  const aDepth = a.split(path.sep).length
  const bDepth = b.split(path.sep).length
  return bDepth - aDepth