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/recipe-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/recipe-helpers.js')
-rw-r--r-- | src/helpers/recipe-helpers.js | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/helpers/recipe-helpers.js b/src/helpers/recipe-helpers.js index 7daa0aaab..7e4bfa85a 100644 --- a/src/helpers/recipe-helpers.js +++ b/src/helpers/recipe-helpers.js | |||
@@ -1,12 +1,12 @@ | |||
1 | import path from 'path'; | 1 | import { parse } from 'path'; |
2 | import { app } from '@electron/remote'; | 2 | import { userDataRecipesPath } from '../environment'; |
3 | 3 | ||
4 | export function getRecipeDirectory(id = '') { | 4 | export function getRecipeDirectory(id = '') { |
5 | return path.join(app.getPath('userData'), 'recipes', id); | 5 | return userDataRecipesPath(id); |
6 | } | 6 | } |
7 | 7 | ||
8 | export function getDevRecipeDirectory(id = '') { | 8 | export function getDevRecipeDirectory(id = '') { |
9 | return path.join(app.getPath('userData'), 'recipes', 'dev', id); | 9 | return userDataRecipesPath('dev', id); |
10 | } | 10 | } |
11 | 11 | ||
12 | export function loadRecipeConfig(recipeId) { | 12 | export function loadRecipeConfig(recipeId) { |
@@ -19,8 +19,7 @@ export function loadRecipeConfig(recipeId) { | |||
19 | let config = require(configPath); | 19 | let config = require(configPath); |
20 | 20 | ||
21 | const moduleConfigPath = require.resolve(configPath); | 21 | const moduleConfigPath = require.resolve(configPath); |
22 | const paths = path.parse(moduleConfigPath); | 22 | config.path = parse(moduleConfigPath).dir; |
23 | config.path = paths.dir; | ||
24 | 23 | ||
25 | return config; | 24 | return config; |
26 | } catch (e) { | 25 | } catch (e) { |