| 1 | import { app } from 'electron' |
| 2 | import { is } from '@electron-toolkit/utils' |
| 3 | import path from 'node:path' |
| 4 | import { mkdir } from 'node:fs/promises' |
| 5 | import { allowLocalAssetRoot } from '../io/local-asset-roots' |
| 6 | |
| 7 | export function resolveBundledStylesSourcePath(): string { |
| 8 | return is.dev |
| 9 | ? path.join(process.cwd(), 'resources', 'styles') |
| 10 | : path.join(process.resourcesPath, 'app.asar.unpacked', 'resources', 'styles') |
| 11 | } |
| 12 | |
| 13 | export function resolveInstalledStylesPath(): string { |
| 14 | return path.join(app.getPath('userData'), is.dev ? 'styles-dev' : 'styles') |
| 15 | } |
| 16 | |
| 17 | export async function ensureInstalledStylesPath(installedRootPath: string): Promise<void> { |
| 18 | await mkdir(path.join(installedRootPath, 'system'), { recursive: true }) |
| 19 | await mkdir(path.join(installedRootPath, 'user'), { recursive: true }) |
| 20 | allowLocalAssetRoot(installedRootPath) |
| 21 | } |
| 22 |