Skip to content

Commit d405f23

Browse files
authored
fix: set timeout of openChrome.applescript (vuejs#5390)
1 parent caa3006 commit d405f23

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

packages/@vue/cli-shared-utils/lib/openChrome.applescript

+34-32
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,45 @@ property targetWindow: null
1313
on run argv
1414
set theURL to item 1 of argv
1515

16-
tell application "Chrome"
16+
with timeout of 2 seconds
17+
tell application "Chrome"
1718

18-
if (count every window) = 0 then
19-
make new window
20-
end if
19+
if (count every window) = 0 then
20+
make new window
21+
end if
2122

22-
-- 1: Looking for tab running debugger
23-
-- then, Reload debugging tab if found
24-
-- then return
25-
set found to my lookupTabWithUrl(theURL)
26-
if found then
27-
set targetWindow's active tab index to targetTabIndex
28-
tell targetTab to reload
29-
tell targetWindow to activate
30-
set index of targetWindow to 1
31-
return
32-
end if
23+
-- 1: Looking for tab running debugger
24+
-- then, Reload debugging tab if found
25+
-- then return
26+
set found to my lookupTabWithUrl(theURL)
27+
if found then
28+
set targetWindow's active tab index to targetTabIndex
29+
tell targetTab to reload
30+
tell targetWindow to activate
31+
set index of targetWindow to 1
32+
return
33+
end if
3334

34-
-- 2: Looking for Empty tab
35-
-- In case debugging tab was not found
36-
-- We try to find an empty tab instead
37-
set found to my lookupTabWithUrl("chrome://newtab/")
38-
if found then
39-
set targetWindow's active tab index to targetTabIndex
40-
set URL of targetTab to theURL
41-
tell targetWindow to activate
42-
return
43-
end if
35+
-- 2: Looking for Empty tab
36+
-- In case debugging tab was not found
37+
-- We try to find an empty tab instead
38+
set found to my lookupTabWithUrl("chrome://newtab/")
39+
if found then
40+
set targetWindow's active tab index to targetTabIndex
41+
set URL of targetTab to theURL
42+
tell targetWindow to activate
43+
return
44+
end if
4445

45-
-- 3: Create new tab
46-
-- both debugging and empty tab were not found
47-
-- make a new tab with url
48-
tell window 1
49-
activate
50-
make new tab with properties {URL:theURL}
46+
-- 3: Create new tab
47+
-- both debugging and empty tab were not found
48+
-- make a new tab with url
49+
tell window 1
50+
activate
51+
make new tab with properties {URL:theURL}
52+
end tell
5153
end tell
52-
end tell
54+
end timeout
5355
end run
5456

5557
-- Function:

0 commit comments

Comments
 (0)