blob: a31c29e72a9c954e6e0911988c08c3ec89ad5a20 (
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
36
37
38
39
|
import path from 'path';
import { remote } from 'electron';
// import ServiceModel from '../models/Service';
const { app } = 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(),
);
|