From 604211c874631ddb1793025b60330cb3573c67b9 Mon Sep 17 00:00:00 2001 From: 374632897 <374632897@qq.com> Date: Wed, 15 Apr 2020 16:12:05 +0800 Subject: [PATCH] fix: set timeout of openChrome.applescript --- .../lib/openChrome.applescript | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/packages/@vue/cli-shared-utils/lib/openChrome.applescript b/packages/@vue/cli-shared-utils/lib/openChrome.applescript index c830f37171..25d496b3aa 100644 --- a/packages/@vue/cli-shared-utils/lib/openChrome.applescript +++ b/packages/@vue/cli-shared-utils/lib/openChrome.applescript @@ -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: