Skip to content

Commit

Permalink
5.0.4: fix path when using Launch Agent for Mac apps
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-lynch committed Dec 3, 2017
1 parent 07c22a6 commit 0a17a62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auto-launch",
"version": "5.0.3",
"version": "5.0.4",
"description": "Launch node applications or executables at login (Mac, Windows, and Linux)",
"main": "dist/index.js",
"scripts": {
Expand Down
8 changes: 5 additions & 3 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ module.exports = class AutoLaunch

# Corrects the path to point to the outer .app
# path - {String}
# macOptions - {Object}
# Returns a {String}
fixMacExecPath: (path) ->
fixMacExecPath: (path, macOptions) ->
# This will match apps whose inner app and executable's basename is the outer app's basename plus "Helper"
# (the default Electron app structure for example)
# It will also match apps whose outer app's basename is different to the rest but the inner app and executable's
Expand All @@ -70,15 +71,16 @@ module.exports = class AutoLaunch
# Also matches when the path is pointing not to the exectuable in the inner app at all but to the Electron
# executable in the outer app
path = path.replace /(^.+?[^\/]+?\.app)\/Contents\/(Frameworks\/((\1|[^\/]+?) Helper)\.app\/Contents\/MacOS\/\3|MacOS\/Electron)/, '$1'
path = path.replace /\.app\/Contents\/MacOS\/[^\/]*$/, '.app'
# When using a launch agent, it needs the inner executable path
path = path.replace /\.app\/Contents\/MacOS\/[^\/]*$/, '.app' unless macOptions.useLaunchAgent
return path


fixOpts: =>
@opts.appPath = @opts.appPath.replace /\/$/, ''

if /darwin/.test process.platform
@opts.appPath = @fixMacExecPath(@opts.appPath)
@opts.appPath = @fixMacExecPath(@opts.appPath, @opts.mac)

if @opts.appPath.indexOf('/') isnt -1
tempPath = @opts.appPath.split '/'
Expand Down

0 comments on commit 0a17a62

Please sign in to comment.