Skip to content

Commit

Permalink
fix: set timeout of openChrome.applescript (#5390)
Browse files Browse the repository at this point in the history
  • Loading branch information
374632897 committed May 6, 2020
1 parent caa3006 commit d405f23
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions packages/@vue/cli-shared-utils/lib/openChrome.applescript
Expand Up @@ -13,43 +13,45 @@ property targetWindow: null
on run argv
set theURL to item 1 of argv

tell application "Chrome"
with timeout of 2 seconds
tell application "Chrome"

if (count every window) = 0 then
make new window
end if
if (count every window) = 0 then
make new window
end if

-- 1: Looking for tab running debugger
-- then, Reload debugging tab if found
-- then return
set found to my lookupTabWithUrl(theURL)
if found then
set targetWindow's active tab index to targetTabIndex
tell targetTab to reload
tell targetWindow to activate
set index of targetWindow to 1
return
end if
-- 1: Looking for tab running debugger
-- then, Reload debugging tab if found
-- then return
set found to my lookupTabWithUrl(theURL)
if found then
set targetWindow's active tab index to targetTabIndex
tell targetTab to reload
tell targetWindow to activate
set index of targetWindow to 1
return
end if

-- 2: Looking for Empty tab
-- In case debugging tab was not found
-- We try to find an empty tab instead
set found to my lookupTabWithUrl("chrome://newtab/")
if found then
set targetWindow's active tab index to targetTabIndex
set URL of targetTab to theURL
tell targetWindow to activate
return
end if
-- 2: Looking for Empty tab
-- In case debugging tab was not found
-- We try to find an empty tab instead
set found to my lookupTabWithUrl("chrome://newtab/")
if found then
set targetWindow's active tab index to targetTabIndex
set URL of targetTab to theURL
tell targetWindow to activate
return
end if

-- 3: Create new tab
-- both debugging and empty tab were not found
-- make a new tab with url
tell window 1
activate
make new tab with properties {URL:theURL}
-- 3: Create new tab
-- both debugging and empty tab were not found
-- make a new tab with url
tell window 1
activate
make new tab with properties {URL:theURL}
end tell
end tell
end tell
end timeout
end run

-- Function:
Expand Down

0 comments on commit d405f23

Please sign in to comment.