Use "shell.openExternal(url)" to open links in external browsers.

This commit is contained in:
Cheng Zhao
2013-05-20 10:05:19 +08:00
parent 7cb6801ce8
commit 8be54136ed
4 changed files with 18 additions and 19 deletions

View File

@@ -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

View File

@@ -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"