Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenHodgson committed Aug 7, 2024
1 parent 564d23c commit db4e113
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
29 changes: 20 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34554,7 +34554,6 @@ const yaml = __nccwpck_require__(4083);

const unityHub = init();
let hubPath = unityHub.hubPath;
let hubVersion = undefined;

function init() {
switch (process.platform) {
Expand Down Expand Up @@ -34585,10 +34584,8 @@ async function Get() {
} catch (error) {
hubPath = await installUnityHub();
}
if (!hubVersion) {
hubVersion = await getInstalledHubVersion();
core.info(`Installed Unity Hub Version: ${hubVersion}`);
}
const hubVersion = await getInstalledHubVersion();
core.info(`Installed Unity Hub Version: ${hubVersion}`);
const latestHubVersion = await getLatestHubVersion();
if (semver.lt(hubVersion, latestHubVersion)) {
hubPath = await installUnityHub();
Expand Down Expand Up @@ -34652,10 +34649,24 @@ async function installUnityHub() {
}

async function getInstalledHubVersion() {
const baseHubPath = await GetHubRootPath(hubPath);
const fileBuffer = asar.extractFile(path.join(baseHubPath, 'resources', 'app.asar'), 'package.json');
const packageJson = JSON.parse(fileBuffer.toString());
return semver.coerce(packageJson.version);
try {
let asarPath = undefined;
const baseHubPath = await GetHubRootPath(hubPath);
switch (process.platform) {
case 'darwin':
asarPath = path.join(baseHubPath, 'Contents', 'Resources', 'app.asar');
break;
default:
asarPath = path.join(baseHubPath, 'resources', 'app.asar.unpacked');
break;
}
await fs.access(asarPath, fs.constants.R_OK);
const fileBuffer = asar.extractFile(asarPath, 'package.json');
const packageJson = JSON.parse(fileBuffer.toString());
return semver.coerce(packageJson.version);
} catch (error) {
return undefined;
}
}

async function getLatestHubVersion() {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

29 changes: 20 additions & 9 deletions src/unity-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const yaml = require('yaml');

const unityHub = init();
let hubPath = unityHub.hubPath;
let hubVersion = undefined;

function init() {
switch (process.platform) {
Expand Down Expand Up @@ -41,10 +40,8 @@ async function Get() {
} catch (error) {
hubPath = await installUnityHub();
}
if (!hubVersion) {
hubVersion = await getInstalledHubVersion();
core.info(`Installed Unity Hub Version: ${hubVersion}`);
}
const hubVersion = await getInstalledHubVersion();
core.info(`Installed Unity Hub Version: ${hubVersion}`);
const latestHubVersion = await getLatestHubVersion();
if (semver.lt(hubVersion, latestHubVersion)) {
hubPath = await installUnityHub();
Expand Down Expand Up @@ -108,10 +105,24 @@ async function installUnityHub() {
}

async function getInstalledHubVersion() {
const baseHubPath = await GetHubRootPath(hubPath);
const fileBuffer = asar.extractFile(path.join(baseHubPath, 'resources', 'app.asar'), 'package.json');
const packageJson = JSON.parse(fileBuffer.toString());
return semver.coerce(packageJson.version);
try {
let asarPath = undefined;
const baseHubPath = await GetHubRootPath(hubPath);
switch (process.platform) {
case 'darwin':
asarPath = path.join(baseHubPath, 'Contents', 'Resources', 'app.asar');
break;
default:
asarPath = path.join(baseHubPath, 'resources', 'app.asar.unpacked');
break;
}
await fs.access(asarPath, fs.constants.R_OK);
const fileBuffer = asar.extractFile(asarPath, 'package.json');
const packageJson = JSON.parse(fileBuffer.toString());
return semver.coerce(packageJson.version);
} catch (error) {
return undefined;
}
}

async function getLatestHubVersion() {
Expand Down

0 comments on commit db4e113

Please sign in to comment.