Skip to content

Commit

Permalink
Merge pull request #12 from htor/check-install
Browse files Browse the repository at this point in the history
check for other macos install path
  • Loading branch information
htor committed Oct 30, 2020
2 parents c802c59 + d460379 commit 5290f91
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
24 changes: 15 additions & 9 deletions scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
const fs = require('fs')
const path = require('path')
const glob = require('glob')
const package = require('../package.json')
const { app, dialog, BrowserWindow } = require('electron')
const { TEMP_PATH, INSTALLATION_PATH, APPSUPPORT_PATH } = require('./utils')
const { LOGFILE_PATH, INSTALLATION_PATH, APPSUPPORT_PATH } = require('./utils')
let mainWindow

if (require('electron-squirrel-startup')) return

function log (message) {
console.error(message)
fs.appendFileSync(LOGFILE_PATH, `${message}\n`, 'utf8')
}

function showError (message) {
const target = mainWindow || null
const logFile = path.resolve(TEMP_PATH, 'hadron-editor.txt')
const advice = `See ${logFile} for details`
const advice = `See ${LOGFILE_PATH} for details`
message = message ? `${message.toString()}\n${advice}` : advice
log(`Error: ${message}`)
dialog.showMessageBoxSync(target, {
type: 'error',
message: 'Oops! Something bad happened',
detail: message ? `${message}\n\n${advice}` : advice
detail: message
})
message = `\n${new Date().toLocaleString()}\nError: ${message.toString()}`
console.error(message)
fs.appendFileSync(logFile, message)
}

function showConfirmation (question, message) {
Expand Down Expand Up @@ -72,6 +74,10 @@ function createWindow () {
app.commandLine.appendSwitch('disable-site-isolation-trials')

app.on('ready', async () => {
log(`\nhadron v${package.version}`);
log(`Executable path: ${INSTALLATION_PATH}`);
log(`Application files path: ${APPSUPPORT_PATH}`);
log(`Log file path: ${LOGFILE_PATH}`);
checkInstallation()
createWindow()
})
Expand Down
7 changes: 4 additions & 3 deletions scripts/utils.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
const os = require('os')
const glob = require('glob')
const path = require('path')

const USERNAME = os.userInfo().username
const TEMP_PATH = os.tmpdir()
const LOGFILE_PATH = path.resolve(os.tmpdir(), 'hadron-log.txt')
let INSTALLATION_PATH = ''
let APPSUPPORT_PATH = ''

if (process.platform === 'win32') {
INSTALLATION_PATH = glob.sync('\\Program\ Files*\\SuperCollider*')[0] + '\\sclang.exe'
APPSUPPORT_PATH = `C:\\Users\\${USERNAME}\\AppData\\Local\\SuperCollider\\Help`
} else if (process.platform === 'darwin') {
INSTALLATION_PATH = '/Applications/SuperCollider/SuperCollider.app/Contents/MacOS/sclang'
INSTALLATION_PATH = glob.sync('/Applications/SuperCollider*/**/Contents/MacOS/sclang')[0]
APPSUPPORT_PATH = `/Users/${USERNAME}/Library/Application Support/SuperCollider/Help`
}

exports.TEMP_PATH = TEMP_PATH
exports.INSTALLATION_PATH = INSTALLATION_PATH
exports.APPSUPPORT_PATH = APPSUPPORT_PATH
exports.LOGFILE_PATH = LOGFILE_PATH

0 comments on commit 5290f91

Please sign in to comment.