diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-11-04 00:11:41 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2017-11-04 00:11:41 +0100 |
commit | def4b27e980da4e32f494c6832c1851e3364a252 (patch) | |
tree | 520d42e0f24429a42da00ae36fe975c48a591627 /src/api | |
parent | fix(App): Add checks to service url validation to prevent app freeze (diff) | |
download | ferdium-app-def4b27e980da4e32f494c6832c1851e3364a252.tar.gz ferdium-app-def4b27e980da4e32f494c6832c1851e3364a252.tar.zst ferdium-app-def4b27e980da4e32f494c6832c1851e3364a252.zip |
Improve (dev) recipe loading
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/server/ServerApi.js | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js index 8b0b7563c..932b70cdc 100644 --- a/src/api/server/ServerApi.js +++ b/src/api/server/ServerApi.js | |||
@@ -499,7 +499,7 @@ export default class ServerApi { | |||
499 | 499 | ||
500 | return recipe; | 500 | return recipe; |
501 | }), | 501 | }), |
502 | ).catch(err => console.error(err)); | 502 | ).catch(err => console.error('Can\'t load recipe', err)); |
503 | } | 503 | } |
504 | 504 | ||
505 | _mapRecipePreviewModel(recipes) { | 505 | _mapRecipePreviewModel(recipes) { |
@@ -562,9 +562,16 @@ export default class ServerApi { | |||
562 | .filter(file => fs.statSync(path.join(recipesDirectory, file)).isDirectory() && file !== 'temp'); | 562 | .filter(file => fs.statSync(path.join(recipesDirectory, file)).isDirectory() && file !== 'temp'); |
563 | 563 | ||
564 | const recipes = paths.map((id) => { | 564 | const recipes = paths.map((id) => { |
565 | // eslint-disable-next-line | 565 | let Recipe; |
566 | const Recipe = require(id)(RecipeModel); | 566 | try { |
567 | return new Recipe(loadRecipeConfig(id)); | 567 | // eslint-disable-next-line |
568 | Recipe = require(id)(RecipeModel); | ||
569 | return new Recipe(loadRecipeConfig(id)); | ||
570 | } catch (err) { | ||
571 | console.error(err); | ||
572 | } | ||
573 | |||
574 | return false; | ||
568 | }).filter(recipe => recipe.id).map((data) => { | 575 | }).filter(recipe => recipe.id).map((data) => { |
569 | const recipe = data; | 576 | const recipe = data; |
570 | 577 | ||
@@ -579,7 +586,7 @@ export default class ServerApi { | |||
579 | 586 | ||
580 | return recipes; | 587 | return recipes; |
581 | } catch (err) { | 588 | } catch (err) { |
582 | console.debug('Folder `recipe/dev` does not exist'); | 589 | console.debug('Could not load dev recipes'); |
583 | return false; | 590 | return false; |
584 | } | 591 | } |
585 | } | 592 | } |