aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers/recipe-helpers.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-10-13 12:29:40 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-10-13 12:29:40 +0200
commit58cda9cc7fb79ca9df6746de7f9662bc08dc156a (patch)
tree1211600c2a5d3b5f81c435c6896618111a611720 /src/helpers/recipe-helpers.js
downloadferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.gz
ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.zst
ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.zip
initial commit
Diffstat (limited to 'src/helpers/recipe-helpers.js')
-rw-r--r--src/helpers/recipe-helpers.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/helpers/recipe-helpers.js b/src/helpers/recipe-helpers.js
new file mode 100644
index 000000000..257e322fb
--- /dev/null
+++ b/src/helpers/recipe-helpers.js
@@ -0,0 +1,39 @@
1import path from 'path';
2import { remote } from 'electron';
3
4// import ServiceModel from '../models/Service';
5
6const app = remote.app;
7
8export function getRecipeDirectory(id = '') {
9 return path.join(app.getPath('userData'), 'recipes', id);
10}
11
12export function getDevRecipeDirectory(id = '') {
13 return path.join(app.getPath('userData'), 'recipes', 'dev', id);
14}
15
16export function loadRecipeConfig(recipeId) {
17 try {
18 const configPath = `${recipeId}/package.json`;
19 // Delete module from cache
20 delete require.cache[require.resolve(configPath)];
21
22 // eslint-disable-next-line
23 let config = require(configPath);
24
25 const moduleConfigPath = require.resolve(configPath);
26 const paths = path.parse(moduleConfigPath);
27 config.path = paths.dir;
28
29 return config;
30 } catch (e) {
31 console.error(e);
32 return null;
33 }
34}
35
36module.paths.unshift(
37 getDevRecipeDirectory(),
38 getRecipeDirectory(),
39);