diff --git a/spec/app/window-spec.coffee b/spec/app/window-spec.coffee index 989face89..a8ff9998b 100644 --- a/spec/app/window-spec.coffee +++ b/spec/app/window-spec.coffee @@ -232,22 +232,22 @@ describe "Window", -> describe "when a link is clicked", -> it "opens the http/https links in an external application", -> - ChildProcess = require 'child_process' - spyOn(ChildProcess, 'spawn') + shell = require 'shell' + spyOn(shell, 'openExternal') $("the website").appendTo(document.body).click().remove() - expect(ChildProcess.spawn).toHaveBeenCalled() - expect(ChildProcess.spawn.argsForCall[0][1][0]).toBe "http://github.com" + expect(shell.openExternal).toHaveBeenCalled() + expect(shell.openExternal.argsForCall[0]).toBe "http://github.com" - ChildProcess.spawn.reset() + shell.openExternal.reset() $("the website").appendTo(document.body).click().remove() - expect(ChildProcess.spawn).toHaveBeenCalled() - expect(ChildProcess.spawn.argsForCall[0][1][0]).toBe "https://github.com" + expect(shell.openExternal).toHaveBeenCalled() + expect(shell.openExternal.argsForCall[0]).toBe "https://github.com" - ChildProcess.spawn.reset() + shell.openExternal.reset() $("the website").appendTo(document.body).click().remove() - expect(ChildProcess.spawn).not.toHaveBeenCalled() + expect(shell.openExternal).not.toHaveBeenCalled() - ChildProcess.spawn.reset() + shell.openExternal.reset() $("link").appendTo(document.body).click().remove() - expect(ChildProcess.spawn).not.toHaveBeenCalled() + expect(shell.openExternal).not.toHaveBeenCalled() diff --git a/src/app/window.coffee b/src/app/window.coffee index af93a0478..8d9b68f09 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -125,7 +125,7 @@ window.handleEvents = -> return if location[0] is '#' if location.indexOf('https://') is 0 or location.indexOf('http://') is 0 - require('child_process').spawn('open', [location]) + require('shell').openExternal(location) false window.handleDragDrop = -> diff --git a/src/packages/link/lib/link.coffee b/src/packages/link/lib/link.coffee index 56c1ee05b..542fad8da 100644 --- a/src/packages/link/lib/link.coffee +++ b/src/packages/link/lib/link.coffee @@ -12,5 +12,4 @@ module.exports = @selector = new TextMateScopeSelector('markup.underline.link') if @selector.matches(token.scopes) - ChildProcess = require 'child_process' - ChildProcess.spawn 'open', [token.value] + require('shell').openExternal token.value diff --git a/src/packages/link/spec/link-spec.coffee b/src/packages/link/spec/link-spec.coffee index 26b0a4cb6..2e185c19d 100644 --- a/src/packages/link/spec/link-spec.coffee +++ b/src/packages/link/spec/link-spec.coffee @@ -1,6 +1,6 @@ RootView = require 'root-view' Editor = require 'editor' -ChildProcess = require 'child_process' +shell = require 'shell' describe "link package", -> [editor] = [] @@ -17,12 +17,12 @@ describe "link package", -> describe "when the cursor is on a link", -> it "opens the link using the 'open' command", -> - spyOn(ChildProcess, 'spawn') + spyOn(shell, 'openExternal') editor.trigger('link:open') - expect(ChildProcess.spawn).not.toHaveBeenCalled() + expect(shell.openExternal).not.toHaveBeenCalled() editor.setCursorBufferPosition([0,5]) editor.trigger('link:open') - expect(ChildProcess.spawn).toHaveBeenCalled() - expect(ChildProcess.spawn.argsForCall[0][1][0]).toBe "http://github.com" + expect(shell.openExternal).toHaveBeenCalled() + expect(shell.openExternal.argsForCall[0]).toBe "http://github.com"