Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mac support #301

Merged
merged 2 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/back/index.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
}