Skip to content

Commit

Permalink
Merge pull request #301 from LindirQuenya/fix-mac-config
Browse files Browse the repository at this point in the history
fix: mac support
  • Loading branch information
colin969 committed Mar 10, 2022
2 parents 52fc632 + 451ce7d commit a146628
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/back/index.ts
Expand Up @@ -244,7 +244,7 @@ async function onProcessMessage(message: any, sendHandle: any): Promise<void> {
state.logFile = new LogFile(
state.isDev ?
path.join(process.cwd(), 'launcher.log')
: path.join(path.dirname(content.exePath), 'launcher.log'));
: path.join(process.platform == 'darwin' ? state.configFolder : path.dirname(content.exePath), 'launcher.log'));

const addLog = (entry: ILogEntry): number => { return state.log.push(entry) - 1; };
global.log = {
Expand All @@ -262,6 +262,12 @@ async function onProcessMessage(message: any, sendHandle: any): Promise<void> {

// Read configs & preferences
state.config = await ConfigFile.readOrCreateFile(path.join(state.configFolder, CONFIG_FILENAME));

// If we're on mac and the flashpoint path is relative, resolve it relative to the configFolder path.
state.config.flashpointPath = process.platform == 'darwin' && state.config.flashpointPath[0] != '/'
? path.resolve(state.configFolder, state.config.flashpointPath)
: state.config.flashpointPath;

// @TODO Figure out why async loading isn't always working?
try {
state.preferences = await PreferencesFile.readOrCreateFile(path.join(state.config.flashpointPath, PREFERENCES_FILENAME));
Expand Down Expand Up @@ -454,7 +460,8 @@ async function onProcessMessage(message: any, sendHandle: any): Promise<void> {
}
});
state.languageWatcher.on('error', console.error);
const langFolder = path.join(content.isDev ? process.cwd() : path.dirname(content.exePath), 'lang');
// On mac, exePath is Flashpoint.app/Contents/MacOS/flashpoint, and lang is at Flashpoint.app/Contents/lang.
const langFolder = path.join(content.isDev ? process.cwd() : process.platform == 'darwin' ? path.resolve(path.dirname(content.exePath), '..') : path.dirname(content.exePath), 'lang');
fs.stat(langFolder, (error) => {
if (!error) { state.languageWatcher.watch(langFolder); }
else {
Expand Down
4 changes: 3 additions & 1 deletion src/main/Util.ts
Expand Up @@ -38,5 +38,7 @@ export function getMainFolderPath(installed: boolean | undefined): string {
? path.join(app.getPath('appData'), 'flashpoint-launcher') // Installed
: isDev
? process.cwd() // Dev
: path.dirname(app.getPath('exe')); // Portable
: process.platform == 'darwin'
? path.resolve(path.dirname(app.getPath('exe')), '../../..')
: path.dirname(app.getPath('exe')); // Portable
}

0 comments on commit a146628

Please sign in to comment.