blob: 7daa0aaab6d75d73c1eb44bb6f29ba1a8e113f4c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import path from 'path';
import { app } from '@electron/remote';
export function getRecipeDirectory(id = '') {
return path.join(app.getPath('userData'), 'recipes', id);
}
export function getDevRecipeDirectory(id = '') {
return path.join(app.getPath('userData'), 'recipes', 'dev', id);
}
export function loadRecipeConfig(recipeId) {
try {
const configPath = `${recipeId}/package.json`;
// Delete module from cache
delete require.cache[require.resolve(configPath)];
// eslint-disable-next-line
let config = require(configPath);
const moduleConfigPath = require.resolve(configPath);
const paths = path.parse(moduleConfigPath);
config.path = paths.dir;
return config;
} catch (e) {
console.error(e);
return null;
}
}
module.paths.unshift(
getDevRecipeDirectory(),
getRecipeDirectory(),
);
|