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
This commit is contained in:
Anton Nikolaev
2020-01-03 10:53:07 -08:00
committed by Facebook Github Bot
parent e7173e060c
commit 901817040c

View File

@@ -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