From 901817040c17909388120f57b988dccd05a624f8 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Fri, 3 Jan 2020 10:53:07 -0800 Subject: [PATCH] Properly resolve path to icons.json in release build Summary: Currently release build fails to launch, because path to icons.json is resolved incorrectly. This change should fix resolving so it will work for both dev and release build. Reviewed By: jknoxville, mweststrate Differential Revision: D19274410 fbshipit-source-id: 9c0a92e1f6808997d08366c8021cd57565c5ae2c --- src/utils/icons.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/utils/icons.js b/src/utils/icons.js index 353c4da02..6614b09cc 100644 --- a/src/utils/icons.js +++ b/src/utils/icons.js @@ -16,9 +16,12 @@ const fs = require('fs'); const path = require('path'); const {remote} = require('electron'); -const iconsPath = fs.existsSync(path.resolve(process.cwd(), 'icons.json')) - ? path.resolve(process.cwd(), 'icons.json') // development - : path.resolve(process.cwd(), 'static', 'icons.json'); // build +const staticPath = path.resolve(__dirname, '..', '..', 'static'); +const appPath = remote ? remote.app.getAppPath() : staticPath; +const iconsPath = fs.existsSync(path.resolve(appPath, 'icons.json')) + ? path.resolve(appPath, 'icons.json') + : path.resolve(staticPath, 'icons.json'); + const ICONS = JSON.parse(fs.readFileSync(iconsPath, {encoding: 'utf8'})); // Takes a string like 'star', or 'star-outline', and converts it to