Skip to content

Commit 7f1696b

Browse files
committed
fix: improve stopping voiceover flow
1 parent fbc45a7 commit 7f1696b

2 files changed

Lines changed: 10 additions & 15 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@guidepup/setup",
3-
"version": "0.24.0-alpha.5",
3+
"version": "0.24.0-alpha.6",
44
"description": "CLI for configuring environments and install screen reader assets for Guidepup.",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

‎src/commands/setup/macOS/ensureLocalPreferencesExist.ts‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ tell application "VoiceOver"
5757
end tell`;
5858

5959
async function stopVoiceOver(): Promise<void> {
60-
await retryOnError(() => runAppleScript(stopVoiceOverApplescript));
61-
62-
await new Promise((resolve) => setTimeout(resolve, 100));
60+
try {
61+
await runAppleScript(stopVoiceOverApplescript);
62+
} catch {
63+
// Swallow
64+
}
6365

6466
try {
6567
execFileSync(
@@ -74,16 +76,9 @@ async function stopVoiceOver(): Promise<void> {
7476
// Swallow
7577
}
7678

77-
await new Promise((resolve) => setTimeout(resolve, 100));
78-
79-
await retryOnError(
80-
() => {
81-
if (isRunning()) {
82-
throw new Error(ERR_SETUP_MACOS_UNABLE_TO_STOP_VOICEOVER);
83-
}
84-
},
85-
{ retries: 10, delay: 100 },
86-
);
79+
if (isRunning()) {
80+
throw new Error(ERR_SETUP_MACOS_UNABLE_TO_STOP_VOICEOVER);
81+
}
8782
}
8883

8984
function preferencesExist(localPlist: string): void {
@@ -120,5 +115,5 @@ export async function ensureLocalPreferencesExist(): Promise<void> {
120115
delay: 100,
121116
});
122117

123-
await stopVoiceOver();
118+
await retryOnError(() => stopVoiceOver(), { retries: 10, delay: 200 });
124119
}

0 commit comments

Comments
 (0)