Skip to content

Commit 04670ad

Browse files
committed
Lint fixes.
1 parent 4e1c663 commit 04670ad

5 files changed

Lines changed: 42 additions & 16 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches: [main]
66
pull_request: {}
7+
workflow_dispatch: {}
78

89
permissions:
910
contents: read

cspell.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { cspellConfig } from '@kitschpatrol/cspell-config'
22

33
export default cspellConfig({
44
ignorePaths: ['test/fixtures/anki-data-folder/**/*'],
5-
words: ['afmt', 'bafmt', 'bfont', 'bqfmt', 'flds', 'odid', 'odue', 'pycache', 'sched', 'tmpls'],
5+
words: ['afmt', 'bafmt', 'bfont', 'bqfmt', 'flds', 'odid', 'odue', 'pkill', 'sched', 'tmpls'],
66
})

eslint.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ export default eslintConfig(
55
ignores: ['test/fixtures/anki-data-folder/**/*'],
66
ts: {
77
overrides: {
8+
'depend/ban-dependencies': [
9+
'error',
10+
{
11+
allowed: ['execa'],
12+
},
13+
],
814
'ts/naming-convention': [
915
'error',
1016
{

knip.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { knipConfig } from '@kitschpatrol/knip-config'
22

33
export default knipConfig({
4+
ignoreBinaries: ['anki', 'awk', 'launchctl', 'open', 'osascript', 'pkill', 'taskkill'],
45
ignoreDependencies: ['@kitschpatrol/typescript-config', 'playwright'],
56
})

test/utilities/anki-process.ts

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ const platform =
1616
*/
1717
function findAnkiWindows(): string {
1818
const candidates = [
19-
path.join(os.homedir(), 'scoop', 'apps', 'anki', 'current', 'programfiles', '.venv', 'Scripts', 'anki.exe'),
19+
path.join(
20+
os.homedir(),
21+
'scoop',
22+
'apps',
23+
'anki',
24+
'current',
25+
'programfiles',
26+
'.venv',
27+
'Scripts',
28+
'anki.exe',
29+
),
2030
path.join('C:', 'Program Files', 'Anki', 'anki.exe'),
2131
]
2232

@@ -157,42 +167,50 @@ export async function closeAnki(): Promise<void> {
157167
ankiPid = undefined
158168
}
159169

160-
await execa('pkill', ['-x', 'anki']).catch(() => {})
170+
await execa('pkill', ['-x', 'anki']).catch(() => {
171+
// Ignore
172+
})
161173
break
162174
}
163175

164176
case 'mac': {
165-
if (ankiPid !== undefined) {
177+
if (ankiPid === undefined) {
178+
await execa('osascript', ['-e', 'tell application "Anki" to quit']).catch(async () => {
179+
await execa('sh', [
180+
'-c',
181+
"launchctl stop $(launchctl list | grep ankiweb | awk '{print $3}')",
182+
]).catch(() => {
183+
// Ignore
184+
})
185+
})
186+
} else {
166187
try {
167188
process.kill(-ankiPid, 'SIGKILL')
168189
} catch {
169190
// Ignore if process group already exited
170191
}
171192

172193
ankiPid = undefined
173-
} else {
174-
await execa('osascript', ['-e', 'tell application "Anki" to quit']).catch(
175-
async () => {
176-
await execa('sh', [
177-
'-c',
178-
"launchctl stop $(launchctl list | grep ankiweb | awk '{print $3}')",
179-
]).catch(() => {})
180-
},
181-
)
182194
}
183195

184196
// Fallback for pip-installed Anki in worker processes where ankiPid is lost
185-
await execa('pkill', ['-9', '-f', 'bin/anki']).catch(() => {})
197+
await execa('pkill', ['-9', '-f', 'bin/anki']).catch(() => {
198+
// Ignore
199+
})
186200
break
187201
}
188202

189203
case 'windows': {
190204
if (ankiPid !== undefined) {
191-
await execa('taskkill', ['/PID', String(ankiPid), '/T', '/F']).catch(() => {})
205+
await execa('taskkill', ['/PID', String(ankiPid), '/T', '/F']).catch(() => {
206+
// Ignore
207+
})
192208
ankiPid = undefined
193209
}
194210

195-
await execa('taskkill', ['/IM', 'anki.exe', '/T', '/F']).catch(() => {})
211+
await execa('taskkill', ['/IM', 'anki.exe', '/T', '/F']).catch(() => {
212+
// Ignore
213+
})
196214
break
197215
}
198216
}

0 commit comments

Comments
 (0)