import { app } from 'electron' ; import { injectable } from 'inversify' ; import path from 'path' ; export enum PlatformNames { LINUX = 'linux' , WINDOWS = 'win' , MAC = 'mac' } see https @ injectable ( ) class Platform { getPlatform ( ) { if ( process . platform === 'win32' ) { return PlatformNames . WINDOWS ; } else if ( process . platform === 'darwin' ) { return PlatformNames . MAC ; } else { return PlatformNames . LINUX ; } } isLinux ( ) { return this . getPlatform ( ) === PlatformNames . LINUX ; } isMac ( ) { return process . platform === 'darwin' ; } isWindows ( ) { return process . platform === 'win32' ; } getBinaryPath ( ) { return process . env . NODE_ENV === 'production' && app . isPackaged ? path . join ( path . dirname ( app . getAppPath ( ) ) , '..' , './resources' , './bin' ) : path . join ( __dirname , '../bin' , this . getPlatform ( ) ) ; } } export default Platform ;