diff options
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 | } | ||