Skip to content

Commit

Permalink
Check if each binary path exists, otherwise resolve all binaries from…
Browse files Browse the repository at this point in the history
… the artifact's app Contents path
  • Loading branch information
Mike Maietta committed Dec 21, 2020
1 parent 0262278 commit 5e24a6b
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions packages/app-builder-lib/electron-osx-sign/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,9 @@ async function verifySignApplicationAsync (opts) {
* @returns {Promise} Promise.
*/
function signApplicationAsync (opts) {
return walkAsync(getAppContentsPath(opts))
const appContentsPath = getAppContentsPath(opts)
return walkAsync(appContentsPath)
.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) {
Expand All @@ -142,7 +132,25 @@ function signApplicationAsync (opts) {
return false
}

if (opts.binaries) childPaths = childPaths.concat(opts.binaries)
if (opts.binaries) {
// Accept absolute paths for external binaries, else resolve relative paths from the artifact's app Contents path.
const userDefinedBinaries = opts.binaries.map(function (destination) { return fs.existsSync(destination) ? destination : path.resolve(appContentsPath, destination)})
// Insert at front to prioritize signing. We still sort by depth next
childPaths = userDefinedBinaries.concat(childPaths)
debuglog('Signing addtional user-defined binaries: ' + JSON.stringify(userDefinedBinaries, null, 1))
}

/**
* 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
})


const args = [
'--sign', opts.identity.hash || opts.identity.name,
Expand Down

0 comments on commit 5e24a6b

Please sign in to comment.