forked from lightningpixel/modly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
23 lines (20 loc) · 834 Bytes
/
Copy pathutils.ts
File metadata and controls
23 lines (20 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { AnyExtension } from '@shared/types/electron.d'
export function formatModelName(id: string): string {
return id
.replace(/-/g, ' ')
.replace(/\b\w/g, (c) => c.toUpperCase())
}
export function isExtensionRepairable(extension: AnyExtension): boolean {
if (extension.type !== 'model') return false
if (!extension.corrupted) return true
return !extension.builtin && extension.manifestError === 'incomplete'
}
export async function finishExtensionRepair(
result: { success: boolean; error?: string },
refreshExtensions: () => void | Promise<void>,
): Promise<string | null> {
// Quarantine begins before setup, so even a failed Repair changes which
// extensions may appear in renderer/workflow state.
await refreshExtensions()
return result.success ? null : (result.error ?? 'Repair failed')
}