diff --git a/src/atom-application.coffee b/src/atom-application.coffee index 530a4bec9..bdb0c4cd2 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -38,7 +38,7 @@ class AtomApplication installUpdate: null version: null - constructor: ({@resourcePath, pathsToOpen, @version, test, pidToKillWhenClosed, @dev}) -> + constructor: ({@resourcePath, pathsToOpen, @version, test, pidToKillWhenClosed, @dev, newWindow}) -> global.atomApplication = this @pidsToOpenWindows = {} @@ -58,10 +58,10 @@ class AtomApplication if test @runSpecs(true) else if pathsToOpen.length > 0 - @openPaths(pathsToOpen, pidToKillWhenClosed) + @openPaths(pathsToOpen, pidToKillWhenClosed, newWindow) else # Always open a editor window if this is the first instance of Atom. - @openPath(null) + @openPath(null, pidToKillWhenClosed, newWindow) removeWindow: (window) -> @windows.splice @windows.indexOf(window), 1 @@ -96,8 +96,8 @@ class AtomApplication fs.unlinkSync socketPath if fs.existsSync(socketPath) server = net.createServer (connection) => connection.on 'data', (data) => - {pathsToOpen, pidToKillWhenClosed} = JSON.parse(data) - @openPaths(pathsToOpen, pidToKillWhenClosed) + {pathsToOpen, pidToKillWhenClosed, newWindow} = JSON.parse(data) + @openPaths(pathsToOpen, pidToKillWhenClosed, newWindow) server.listen socketPath server.on 'error', (error) -> console.error 'Application server failed', error @@ -223,11 +223,11 @@ class AtomApplication for atomWindow in @windows return atomWindow if atomWindow.containsPath(pathToOpen) - openPaths: (pathsToOpen=[], pidToKillWhenClosed) -> - @openPath(pathToOpen, pidToKillWhenClosed) for pathToOpen in pathsToOpen + openPaths: (pathsToOpen=[], pidToKillWhenClosed, newWindow) -> + @openPath(pathToOpen, pidToKillWhenClosed, newWindow) for pathToOpen in pathsToOpen - openPath: (pathToOpen, pidToKillWhenClosed) -> - existingWindow = @windowForPath(pathToOpen) unless pidToKillWhenClosed + openPath: (pathToOpen, pidToKillWhenClosed, newWindow) -> + existingWindow = @windowForPath(pathToOpen) unless pidToKillWhenClosed or newWindow if existingWindow openedWindow = existingWindow openedWindow.openPath(pathToOpen) diff --git a/src/main.coffee b/src/main.coffee index bbb82784e..aaf3438a2 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -59,6 +59,7 @@ parseCommandLine = -> """ options.alias('d', 'dev').boolean('d').describe('d', 'Run in development mode.') options.alias('h', 'help').boolean('h').describe('h', 'Print this usage message.') + options.alias('n', 'new-window').boolean('n').describe('n', 'Open a new window.') options.alias('t', 'test').boolean('t').describe('t', 'Run the Atom specs and exit with error code on failures.') options.alias('w', 'wait').boolean('w').describe('w', 'Wait for window to be closed before returning.') args = options.argv @@ -71,6 +72,7 @@ parseCommandLine = -> pathsToOpen = args._ pathsToOpen = [executedFrom] if executedFrom and pathsToOpen.length is 0 test = args['test'] + newWindow = args['new-window'] pidToKillWhenClosed = args['pid'] if args['wait'] if args['resource-path'] @@ -85,4 +87,4 @@ parseCommandLine = -> dev = false resourcePath = path.dirname(__dirname) - {resourcePath, pathsToOpen, executedFrom, test, version, pidToKillWhenClosed, dev} + {resourcePath, pathsToOpen, executedFrom, test, version, pidToKillWhenClosed, dev, newWindow}