From 0f6da42075721b51fc696aca5ed54c315715df99 Mon Sep 17 00:00:00 2001 From: Daniel Bayley <daniel.bayley@me.com> Date: Sat, 16 Jul 2016 16:27:50 +0100 Subject: [PATCH] Tidy up --- .editorconfig | 10 +++++++--- README.md | 8 ++++---- index.coffee | 39 +++++++++++++++++++-------------------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/.editorconfig b/.editorconfig index f1e006c..5820b9c 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 5d0ed72..9c87fa6 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 ffd4f52..0985bdd 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 -- GitLab