diff options
Diffstat (limited to 'src/stores/RecipesStore.js')
-rw-r--r-- | src/stores/RecipesStore.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js index b49fb72d9..d2acebb75 100644 --- a/src/stores/RecipesStore.js +++ b/src/stores/RecipesStore.js | |||
@@ -1,13 +1,12 @@ | |||
1 | import { action, computed, observable } from 'mobx'; | 1 | import { action, computed, observable } from 'mobx'; |
2 | import fs from 'fs-extra'; | 2 | import { readJSONSync } from 'fs-extra'; |
3 | import path from 'path'; | ||
4 | import semver from 'semver'; | 3 | import semver from 'semver'; |
5 | 4 | ||
6 | import Store from './lib/Store'; | 5 | import Store from './lib/Store'; |
7 | import CachedRequest from './lib/CachedRequest'; | 6 | import CachedRequest from './lib/CachedRequest'; |
8 | import Request from './lib/Request'; | 7 | import Request from './lib/Request'; |
9 | import { matchRoute } from '../helpers/routing-helpers'; | 8 | import { matchRoute } from '../helpers/routing-helpers'; |
10 | import { RECIPES_PATH } from '../environment'; | 9 | import { asarRecipesPath } from '../environment'; |
11 | 10 | ||
12 | const debug = require('debug')('Ferdi:RecipeStore'); | 11 | const debug = require('debug')('Ferdi:RecipeStore'); |
13 | 12 | ||
@@ -54,11 +53,11 @@ export default class RecipesStore extends Store { | |||
54 | } | 53 | } |
55 | 54 | ||
56 | @computed get recipeIdForServices() { | 55 | @computed get recipeIdForServices() { |
57 | return this.stores.services.all.map(s => s.recipe.id); | 56 | return this.stores.services.all.map((s) => s.recipe.id); |
58 | } | 57 | } |
59 | 58 | ||
60 | one(id) { | 59 | one(id) { |
61 | return this.all.find(recipe => recipe.id === id); | 60 | return this.all.find((recipe) => recipe.id === id); |
62 | } | 61 | } |
63 | 62 | ||
64 | isInstalled(id) { | 63 | isInstalled(id) { |
@@ -78,7 +77,7 @@ export default class RecipesStore extends Store { | |||
78 | const recipes = {}; | 77 | const recipes = {}; |
79 | 78 | ||
80 | // Hackfix, reference this.all to fetch services | 79 | // Hackfix, reference this.all to fetch services |
81 | debug(`Check Recipe updates for ${this.all.map(recipe => recipe.id)}`); | 80 | debug(`Check Recipe updates for ${this.all.map((recipe) => recipe.id)}`); |
82 | 81 | ||
83 | recipeIds.forEach((r) => { | 82 | recipeIds.forEach((r) => { |
84 | const recipe = this.one(r); | 83 | const recipe = this.one(r); |
@@ -90,15 +89,15 @@ export default class RecipesStore extends Store { | |||
90 | const remoteUpdates = await this.getRecipeUpdatesRequest.execute(recipes)._promise; | 89 | const remoteUpdates = await this.getRecipeUpdatesRequest.execute(recipes)._promise; |
91 | 90 | ||
92 | // Check for local updates | 91 | // Check for local updates |
93 | const allJsonFile = path.join(RECIPES_PATH, 'all.json'); | 92 | const allJsonFile = asarRecipesPath('all.json'); |
94 | const allJson = await fs.readJSON(allJsonFile); | 93 | const allJson = readJSONSync(allJsonFile); |
95 | const localUpdates = []; | 94 | const localUpdates = []; |
96 | 95 | ||
97 | Object.keys(recipes).forEach((recipe) => { | 96 | Object.keys(recipes).forEach((recipe) => { |
98 | const version = recipes[recipe]; | 97 | const version = recipes[recipe]; |
99 | 98 | ||
100 | // Find recipe in local recipe repository | 99 | // Find recipe in local recipe repository |
101 | const localRecipe = allJson.find(r => r.id === recipe); | 100 | const localRecipe = allJson.find((r) => r.id === recipe); |
102 | 101 | ||
103 | if (localRecipe && semver.lt(version, localRecipe.version)) { | 102 | if (localRecipe && semver.lt(version, localRecipe.version)) { |
104 | localUpdates.push(recipe); | 103 | localUpdates.push(recipe); |