From 97d51a7763b14c92ee71ff9a012311dd9498d803 Mon Sep 17 00:00:00 2001 From: Vijay Raghavan Aravamudhan Date: Sun, 8 Aug 2021 00:01:37 +0000 Subject: 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/ --- src/helpers/recipe-helpers.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/helpers/recipe-helpers.js') 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 @@ -import path from 'path'; -import { app } from '@electron/remote'; +import { parse } from 'path'; +import { userDataRecipesPath } from '../environment'; export function getRecipeDirectory(id = '') { - return path.join(app.getPath('userData'), 'recipes', id); + return userDataRecipesPath(id); } export function getDevRecipeDirectory(id = '') { - return path.join(app.getPath('userData'), 'recipes', 'dev', id); + return userDataRecipesPath('dev', id); } export function loadRecipeConfig(recipeId) { @@ -19,8 +19,7 @@ export function loadRecipeConfig(recipeId) { let config = require(configPath); const moduleConfigPath = require.resolve(configPath); - const paths = path.parse(moduleConfigPath); - config.path = paths.dir; + config.path = parse(moduleConfigPath).dir; return config; } catch (e) { -- cgit v1.2.3-70-g09d2