aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers/service-helpers.ts
blob: 678d5024f55b7b18b5140cd6cc27e1643bf6f8b3 (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-remote';

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');
}