aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers/service-helpers.ts
blob: 13c921f8810b464675c2b164058842c99b6a1a27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { readdirSync, removeSync } from 'fs-extra';
import { userDataPath } from '../environment';

export function getServicePartitionsDirectory(...segments) {
  return userDataPath('Partitions', ...[segments].flat());
}

export function removeServicePartitionDirectory(
  id = '',
  addServicePrefix = false,
) {
  const servicePartition = getServicePartitionsDirectory(
    `${addServicePrefix ? 'service-' : ''}${id}`,
  );
  return removeSync(servicePartition);
}

export async function getServiceIdsFromPartitions() {
  const files = readdirSync(getServicePartitionsDirectory());
  return files.filter(n => n !== '__chrome_extension');
}