Skip to content

Commit

Permalink
#19 It now is now portable
Browse files Browse the repository at this point in the history
Nodejs now corrects the portable bin/R script for mac and linux
  • Loading branch information
zekrom-vale committed Mar 14, 2024
1 parent b67344d commit 3179b42
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Modules to control application life and create native browser window
const {app, BrowserWindow} = require('electron')
const path = require('path')
const shell = require('child_process').execSync


const url = require('url')
Expand All @@ -23,7 +24,7 @@ if(process.platform == WINDOWS){
execPath = path.join(app.getAppPath(),"R-Portable-Win", "bin", "RScript.exe" )
}
else if(process.platform == MACOS){
console.log("Experamental platform")
console.log("Experamental UNTESTED platform")
killStr = 'pkill -9 "R"'
var macAbsolutePath = path.join(app.getAppPath(), "R-Portable-Mac")
var env_path = macAbsolutePath+((process.env.PATH)?":"+process.env.PATH:"");
Expand All @@ -47,6 +48,16 @@ else {

console.log(process.env)

// Fix issue with R Home path
if(process.platform == LINUX){
let home=path.join(app.getAppPath(), "R-Portable-Linux" )
shell(`sed -i 's!R_HOME_DIR=.*$!R_HOME_DIR="${home}"!' ${execPath}`)
}
else if(process.platform == MACOS){
let home=path.join(app.getAppPath(), "R-Portable-Mac" )
shell(`sed -i "" 's!R_HOME_DIR=.*$!R_HOME_DIR="${home}"!' ${execPath}`)
}

// Due to an issue with shiny, the port needs to be set via options and not passed to the runApp function
// https://github.com/rstudio/shiny/issues/1942
const childProcess = child.spawn(execPath, ["-e", `options(shiny.port=${port}); shiny::runApp(file.path('${appPath}'))`])
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3179b42

Please sign in to comment.