Skip to content

Commit

Permalink
Execute Unity Hub without sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
kuler90 committed Nov 9, 2020
1 parent 2a71f2b commit a288eae
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ async function installUnityEditor(unityHubPath, installPath, unityVersion, unity
let unityPath = await findUnity(unityHubPath, unityVersion);
if (!unityPath) {
if (installPath) {
await executeHub(unityHubPath, `install-path --set ${installPath}`);
if (process.platform === 'linux' || process.platform === 'darwin') {
await execute(`sudo mkdir -p "${installPath}"`);
await execute(`sudo chmod -R o+rwx "${installPath}"`);
}
await executeHub(unityHubPath, `install-path --set "${installPath}"`);
}
await executeHub(unityHubPath, `install --version ${unityVersion} --changeset ${unityVersionChangeset}`);
unityPath = await findUnity(unityHubPath, unityVersion);
Expand Down Expand Up @@ -152,9 +156,9 @@ async function findVersionChangeset(unityVersion) {

async function executeHub(unityHubPath, args) {
if (process.platform === 'linux') {
return await execute(`sudo xvfb-run --auto-servernum "${unityHubPath}" --no-sandbox --headless ${args}`);
return await execute(`xvfb-run --auto-servernum "${unityHubPath}" --no-sandbox --headless ${args}`);
} else if (process.platform === 'darwin') {
return await execute(`sudo "${unityHubPath}" -- --headless ${args}`);
return await execute(`"${unityHubPath}" -- --headless ${args}`);
} else if (process.platform === 'win32') {
// unityhub always return exit code 1
return await execute(`"${unityHubPath}" -- --headless ${args}`, true);
Expand Down

0 comments on commit a288eae

Please sign in to comment.