From c04ba75cc189933000bfa3acc045f6b3a8798f2e Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Thu, 3 Oct 2013 11:29:34 -0700 Subject: [PATCH] Remove initialization repetition from a second atom process --- src/atom-application.coffee | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/atom-application.coffee b/src/atom-application.coffee index 0f5521082..ffff750b7 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -50,7 +50,8 @@ class AtomApplication resourcePath: null version: null - constructor: ({@resourcePath, pathsToOpen, urlsToOpen, @version, test, pidToKillWhenClosed, devMode, newWindow, specDirectory}) -> + constructor: (options) -> + {@resourcePath, @version} = options global.atomApplication = this @pidsToOpenWindows = {} @@ -65,6 +66,10 @@ class AtomApplication @handleEvents() @checkForUpdates() + @openBasedOnOptions(options) + + # Private: Opens a new window based on the options provided. + openBasedOnOptions: ({pathsToOpen, urlsToOpen, test, pidToKillWhenClosed, devMode, newWindow, specDirectory}) -> if test @runSpecs({exitWhenDone: true, @resourcePath, specDirectory}) else if pathsToOpen.length > 0 @@ -93,8 +98,7 @@ class AtomApplication fs.unlinkSync socketPath if fs.existsSync(socketPath) server = net.createServer (connection) => connection.on 'data', (data) => - options = JSON.parse(data) - @openPaths(options) + @openBasedOnOptions(JSON.parse(data)) server.listen socketPath server.on 'error', (error) -> console.error 'Application server failed', error