Merge pull request #76 from kfranqueiro/rename-helper

Fix #65: Rename Helper application on Mac OS X
This commit is contained in:
=^._.^= 2015-06-27 19:26:42 -05:00
commit b80a060716
1 changed files with 18 additions and 2 deletions

20
mac.js
View File

@ -36,7 +36,8 @@ function buildMacApp (opts, cb, newApp) {
var paths = {
info1: path.join(newApp, 'Contents', 'Info.plist'),
info2: path.join(newApp, 'Contents', 'Frameworks', 'Electron Helper.app', 'Contents', 'Info.plist'),
app: path.join(newApp, 'Contents', 'Resources', 'app')
app: path.join(newApp, 'Contents', 'Resources', 'app'),
helper: path.join(newApp, 'Contents', 'Frameworks', 'Electron Helper.app')
}
// update plist files
@ -73,6 +74,21 @@ function buildMacApp (opts, cb, newApp) {
ncp(opts.dir, paths.app, {filter: common.userIgnoreFilter(opts), dereference: true}, function copied (err) {
if (err) return cb(err)
function moveHelper () {
// Move helper binary before moving the parent helper app directory itself
var helperDestination = path.join(path.dirname(paths.helper), opts.name + ' Helper.app')
var helperBinary = path.join(paths.helper, 'Contents', 'MacOS', 'Electron Helper')
var helperBinaryDestination = path.join(path.dirname(helperBinary), opts.name + ' Helper')
fs.rename(helperBinary, helperBinaryDestination, function (err) {
if (err) return cb(err)
fs.rename(paths.helper, helperDestination, function (err) {
if (err) return cb(err)
moveApp()
})
})
}
function moveApp () {
// finally, move app into cwd
var outdir = opts.out || process.cwd()
@ -139,6 +155,6 @@ function buildMacApp (opts, cb, newApp) {
})
}
common.prune(opts, paths.app, cb, moveApp)
common.prune(opts, paths.app, cb, moveHelper)
})
}