Skip to content
Snippets Groups Projects
Verified Commit 9376c103 authored by Sheogorath's avatar Sheogorath :european_castle:
Browse files

Merge branch 'master' of https://github.com/b3ni/atom-gitkraken into fix/merge-conflict

parents eec72378 c278375e
No related tags found
No related merge requests found
......@@ -55,18 +55,10 @@ module.exports =
#-------------------------------------------------------------------------------
open: ({path}) ->
if @config.get 'singleInstance'
exec "pkill GitKraken; sleep .1 && open -Fb #{@id} --args -p '#{path}'" #, @timeout
if atom.config.get 'gitkraken.singleInstance'
@execGitKrakenSingle path
else
projects = {}
try
projects = require @tmp
execSync "ps #{projects[path]} | grep -q GitKraken &&
open -b #{@id} --args -p '#{path}'"
catch
pid = execSync "open -nb #{@id} --args -p '#{path}' & echo $!"
projects[path] = (parseInt pid) + 1
writeFile @tmp, JSON.stringify projects
projects = @execGitKrakenMulti path
window.addEventListener 'beforeunload', ->
exec "kill #{projects[path]}"
......@@ -76,3 +68,31 @@ module.exports =
@subs.dispose()
window.removeEventListener 'beforeunload'
unlink @tmp
#-------------------------------------------------------------------------------
execGitKrakenSingle: (path) ->
if process.platform == 'darwin'
exec "pkill GitKraken; sleep .1 && open -Fb #{@id} --args -p '#{path}'" #, @timeout
else if process.platform == 'linux'
exec "killall gitkraken; sleep .1 && gitkraken --args -p '#{path}' &> /dev/null &"
#-------------------------------------------------------------------------------
execGitKrakenMulti: (path) ->
projects = {}
try
projects = require @tmp
if process.platform == 'darwin'
execSync "ps #{projects[path]} | grep -q GitKraken && open -b #{@id} --args -p '#{path}'"
else if process.platform == 'linux'
execSync "ps #{projects[path]} | grep -q gitkraken"
catch
if process.platform == 'darwin'
pid = execSync "open -nb #{@id} --args -p '#{path}' & echo $!"
else if process.platform == 'linux'
proc = exec "nohup gitkraken --args -p '#{path}' &>/dev/null &"
pid = proc.pid
projects[path] = (parseInt pid) + 1
writeFile @tmp, JSON.stringify projects
projects
......@@ -19,7 +19,8 @@
"private": true,
"license": "MIT",
"os": [
"darwin"
"darwin",
"linux"
],
"dependencies": {
"sub-atom": "^1.1.0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment