diff --git a/.editorconfig b/.editorconfig index f1e006c75a38a2cecc513eb70164c3bfc73bacf0..5820b9c1822ac45ca488922b9dc573233f230358 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,11 +4,15 @@ root = true end_of_line = LF charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - indent_style = tab indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true + [*.md] trim_trailing_whitespace = false + +[{*.md,package.json}] +indent_style = space +indent_size = 2 diff --git a/README.md b/README.md index 5d0ed726d910d6f1f4dd0c44d1dce25c1ca9c8cd..9c87fa6f4fe63a1678df36c49852c93c80da8bb8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ License ------- [MIT] © [Daniel Bayley] -[MIT]: LICENSE.md -[Daniel Bayley]: https://github.com/danielbayley -[atom]: https://atom.io -[gitkraken]: http://gitkraken.com +[MIT]: LICENSE.md +[Daniel Bayley]: https://github.com/danielbayley +[atom]: https://atom.io +[gitkraken]: http://gitkraken.com diff --git a/index.coffee b/index.coffee index ffd4f52a9732bb0a9bedbab1ad7975c443d3442f..0985bdd2c418b2019c249e5b6a7d264b6e2120af 100644 --- a/index.coffee +++ b/index.coffee @@ -1,44 +1,43 @@ {execSync, exec} = require 'child_process' {writeFile, unlink} = require 'fs' +SubAtom = require 'sub-atom' -tmp = '/tmp/GitKraken.json' -id = 'com.axosoft.GitKraken' -selector = '[class^="status-bar"] .git-branch' - -#------------------------------------------------------------------------------- module.exports = #os: process.platform #timeout: #timeout: 10000 #killSignal: 'SIGKILL' - subs: null - activate: -> - SubAtom = require 'sub-atom' - @subs = new SubAtom + + project: atom.project.getDirectories()[0] + tmp: '/tmp/GitKraken.json' + + id: 'com.axosoft.GitKraken' + selector: '[class^=status-bar] .git-branch' + + subs: new SubAtom #------------------------------------------------------------------------------- + activate: -> @subs.add atom.commands.add 'atom-workspace', - 'gitkraken:release': => @open() + 'gitkraken:release': => @open @project atom.packages.onDidActivateInitialPackages => - @subs.add 'status-bar','click', selector, @open + @subs.add 'status-bar','click', selector, @open @project #------------------------------------------------------------------------------- - open: -> - {path} = atom.project.getDirectories()[0] - + open: ({path}) -> if atom.config.get 'gitkraken.singleInstance' - exec "pkill GitKraken; sleep .1 && open -Fb #{id} --args -p '#{path}'" #, @timeout + exec "pkill GitKraken; sleep .1 && open -Fb #{@id} --args -p '#{path}'" #, @timeout else projects = {} try - projects = require tmp + projects = require @tmp execSync "ps #{projects[path]} | grep -q GitKraken && - open -b #{id} --args -p '#{path}'" + open -b #{@id} --args -p '#{path}'" catch - pid = execSync "open -nb #{id} --args -p '#{path}' & echo $!" + pid = execSync "open -nb #{@id} --args -p '#{path}' & echo $!" projects[path] = (parseInt pid) + 1 - writeFile tmp, JSON.stringify projects + writeFile @tmp, JSON.stringify projects window.addEventListener 'beforeunload', -> exec "kill #{projects[path]}" @@ -47,4 +46,4 @@ module.exports = deactivate: -> @subs.dispose() window.removeEventListener 'beforeunload' - unlink tmp + unlink @tmp