diff --git a/lib/atomic-chrome.coffee b/lib/atomic-chrome.coffee index cb3873a..1115bf4 100644 --- a/lib/atomic-chrome.coffee +++ b/lib/atomic-chrome.coffee @@ -1,8 +1,5 @@ -{CompositeDisposable} = require 'atom' -{Server} = require 'ws' - -WSHandler = require './ws-handler' - +{Server} = require 'ws' +WSHandler = null # defer require till necessary WS_PORT = 64292 module.exports = AtomicChrome = @@ -10,6 +7,7 @@ module.exports = AtomicChrome = @wss = new Server({port: WS_PORT}) @wss.on 'connection', (ws) -> + WSHandler ?= require './ws-handler' new WSHandler(ws) @wss.on 'error', (err) -> console.error(err) unless err.code == 'EADDRINUSE' diff --git a/lib/ws-handler.coffee b/lib/ws-handler.coffee index 347465f..22bbd3d 100644 --- a/lib/ws-handler.coffee +++ b/lib/ws-handler.coffee @@ -13,6 +13,7 @@ module.exports = class WSHandler register: (data) -> filepath = @getFile(data) + atom.focus() # activivate Atom application atom.workspace.open(filepath).then (editor) => @initEditor(editor, data)