diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-09-14 10:34:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-14 10:34:04 +0200 |
commit | 979ec02c9a1019152be08705986337e470eabb57 (patch) | |
tree | 6021179ad8649112717a499780f475275af487f2 /src/helpers/service-helpers.ts | |
parent | refactor: defensive programming to avoid javascript error for unread badges (diff) | |
download | ferdium-app-979ec02c9a1019152be08705986337e470eabb57.tar.gz ferdium-app-979ec02c9a1019152be08705986337e470eabb57.tar.zst ferdium-app-979ec02c9a1019152be08705986337e470eabb57.zip |
chore: codebase improvements (#1930)
Diffstat (limited to 'src/helpers/service-helpers.ts')
-rw-r--r-- | src/helpers/service-helpers.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/helpers/service-helpers.ts b/src/helpers/service-helpers.ts new file mode 100644 index 000000000..13c921f88 --- /dev/null +++ b/src/helpers/service-helpers.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import { readdirSync, removeSync } from 'fs-extra'; | ||
2 | import { userDataPath } from '../environment'; | ||
3 | |||
4 | export function getServicePartitionsDirectory(...segments) { | ||
5 | return userDataPath('Partitions', ...[segments].flat()); | ||
6 | } | ||
7 | |||
8 | export function removeServicePartitionDirectory( | ||
9 | id = '', | ||
10 | addServicePrefix = false, | ||
11 | ) { | ||
12 | const servicePartition = getServicePartitionsDirectory( | ||
13 | `${addServicePrefix ? 'service-' : ''}${id}`, | ||
14 | ); | ||
15 | return removeSync(servicePartition); | ||
16 | } | ||
17 | |||
18 | export async function getServiceIdsFromPartitions() { | ||
19 | const files = readdirSync(getServicePartitionsDirectory()); | ||
20 | return files.filter(n => n !== '__chrome_extension'); | ||
21 | } | ||