From 11f99ffaac3529b1ef61fa5360923a78ee7ce7d5 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Fri, 1 Oct 2021 20:42:54 +0530 Subject: refactor: move 'asarRecipesPath' into 'asar-helpers' --- src/api/server/ServerApi.js | 2 +- src/containers/settings/RecipesScreen.js | 3 ++- src/environment.ts | 7 ------- src/helpers/asar-helpers.ts | 7 +++++++ src/stores/RecipesStore.js | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js index ef3d51796..fb0d64dc3 100644 --- a/src/api/server/ServerApi.js +++ b/src/api/server/ServerApi.js @@ -25,11 +25,11 @@ import { SERVER_NOT_LOADED } from '../../config'; import { osArch, osPlatform, - asarRecipesPath, userDataRecipesPath, userDataPath, ferdiVersion, } from '../../environment'; +import { asarRecipesPath } from '../../helpers/asar-helpers'; import apiBase from '../apiBase'; import { prepareAuthRequest, sendAuthRequest } from '../utils/auth'; diff --git a/src/containers/settings/RecipesScreen.js b/src/containers/settings/RecipesScreen.js index 06ddabe4c..162390d57 100644 --- a/src/containers/settings/RecipesScreen.js +++ b/src/containers/settings/RecipesScreen.js @@ -12,7 +12,8 @@ import UserStore from '../../stores/UserStore'; import RecipesDashboard from '../../components/settings/recipes/RecipesDashboard'; import ErrorBoundary from '../../components/util/ErrorBoundary'; import { CUSTOM_WEBSITE_RECIPE_ID, FRANZ_DEV_DOCS } from '../../config'; -import { asarRecipesPath, userDataRecipesPath } from '../../environment'; +import { userDataRecipesPath } from '../../environment'; +import { asarRecipesPath } from '../../helpers/asar-helpers'; import { communityRecipesStore } from '../../features/communityRecipes'; import RecipePreview from '../../models/RecipePreview'; import AppStore from '../../stores/AppStore'; diff --git a/src/environment.ts b/src/environment.ts index 3e63f449b..9478f803c 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -23,8 +23,6 @@ import { iconSizeBias, } from './config'; -import { asarPath } from './helpers/asar-helpers'; - // @ts-expect-error Cannot find module './buildInfo.json' or its corresponding type declarations. import * as buildInfo from './buildInfo.json'; @@ -64,11 +62,6 @@ export function userDataRecipesPath(...segments: any[]) { return userDataPath('recipes', ...[segments].flat()); } -// Replacing app.asar is not beautiful but unfortunately necessary -export function asarRecipesPath(...segments: any[]) { - return join(asarPath(join(__dirname, 'recipes')), ...[segments].flat()); -} - export const useLiveAPI = process.env.USE_LIVE_API; const useLocalAPI = process.env.USE_LOCAL_API; diff --git a/src/helpers/asar-helpers.ts b/src/helpers/asar-helpers.ts index 3d9f0d941..3da90625d 100644 --- a/src/helpers/asar-helpers.ts +++ b/src/helpers/asar-helpers.ts @@ -1,3 +1,10 @@ +import { join } from 'path'; + export function asarPath(dir: string = '') { return dir.replace('app.asar', 'app.asar.unpacked'); } + +// Replacing app.asar is not beautiful but unfortunately necessary +export function asarRecipesPath(...segments: any[]) { + return join(asarPath(join(__dirname, '..', 'recipes')), ...[segments].flat()); +} diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js index bfbdc57a8..95d662e79 100644 --- a/src/stores/RecipesStore.js +++ b/src/stores/RecipesStore.js @@ -6,7 +6,7 @@ import Store from './lib/Store'; import CachedRequest from './lib/CachedRequest'; import Request from './lib/Request'; import { matchRoute } from '../helpers/routing-helpers'; -import { asarRecipesPath } from '../environment'; +import { asarRecipesPath } from '../helpers/asar-helpers'; const debug = require('debug')('Ferdi:RecipeStore'); -- cgit v1.2.3-70-g09d2