diff options
author | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2021-08-08 00:01:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-08 05:31:37 +0530 |
commit | 97d51a7763b14c92ee71ff9a012311dd9498d803 (patch) | |
tree | bd36005031ecb1148f27aa541e7a92a5e3aa4c0c /src/helpers/service-helpers.js | |
parent | 5.6.1-nightly.17 [skip ci] (diff) | |
download | ferdium-app-97d51a7763b14c92ee71ff9a012311dd9498d803.tar.gz ferdium-app-97d51a7763b14c92ee71ff9a012311dd9498d803.tar.zst ferdium-app-97d51a7763b14c92ee71ff9a012311dd9498d803.zip |
refactor: path-references refactoring and using 'import' instead of 'require' (#1752)
* refactor references to 'userData' and 'appData' directories to move hardcoding into single location
* convert to es6 for lower memory usage as per https://codesource.io/the-difference-between-import-and-require-in-javascript/
Diffstat (limited to 'src/helpers/service-helpers.js')
-rw-r--r-- | src/helpers/service-helpers.js | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/helpers/service-helpers.js b/src/helpers/service-helpers.js index 28d483182..745f40dd9 100644 --- a/src/helpers/service-helpers.js +++ b/src/helpers/service-helpers.js | |||
@@ -1,18 +1,16 @@ | |||
1 | import path from 'path'; | 1 | import { readdirSync, removeSync } from 'fs-extra'; |
2 | import { app } from '@electron/remote'; | 2 | import { userDataPath } from '../environment'; |
3 | import fs from 'fs-extra'; | ||
4 | 3 | ||
5 | export function getServicePartitionsDirectory() { | 4 | export function getServicePartitionsDirectory(...segments) { |
6 | return path.join(app.getPath('userData'), 'Partitions'); | 5 | return userDataPath('Partitions', ...([segments].flat())); |
7 | } | 6 | } |
8 | 7 | ||
9 | export function removeServicePartitionDirectory(id = '', addServicePrefix = false) { | 8 | export function removeServicePartitionDirectory(id = '', addServicePrefix = false) { |
10 | const servicePartition = path.join(getServicePartitionsDirectory(), `${addServicePrefix ? 'service-' : ''}${id}`); | 9 | const servicePartition = getServicePartitionsDirectory(`${addServicePrefix ? 'service-' : ''}${id}`); |
11 | 10 | return removeSync(servicePartition); | |
12 | return fs.remove(servicePartition); | ||
13 | } | 11 | } |
14 | 12 | ||
15 | export async function getServiceIdsFromPartitions() { | 13 | export async function getServiceIdsFromPartitions() { |
16 | const files = await fs.readdir(getServicePartitionsDirectory()); | 14 | const files = readdirSync(getServicePartitionsDirectory()); |
17 | return files.filter((n) => n !== '__chrome_extension'); | 15 | return files.filter((n) => n !== '__chrome_extension'); |
18 | } | 16 | } |