Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 31 additions & 30 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4235,41 +4235,42 @@ class UnityEditor {
this.version = version;
}
this.autoAddNoGraphics = this.version.isGreaterThan('2018.0.0');
// check if we have permissions to write to this file
try {
fs.accessSync(this.editorRootPath, fs.constants.W_OK);
}
catch (error) {
return;
}
// ensure metadata.hub.json exists and has a productName entry
const hubMetaDataPath = path.join(this.editorRootPath, 'metadata.hub.json');
if (!fs.existsSync(hubMetaDataPath)) {
const metadata = {
productName: `Unity ${this.version.version.toString()}`,
entitlements: [],
releaseStream: '',
isLTS: null
};
fs.writeFileSync(hubMetaDataPath, JSON.stringify(metadata), { encoding: 'utf-8' });
}
else {
const metadataContent = fs.readFileSync(hubMetaDataPath, { encoding: 'utf-8' });
const metadata = JSON.parse(metadataContent);
if (!metadata.productName) {
// projectName must be the first property
const newMetadata = {
productName: `Unity ${this.version.version.toString()}`
try {
// check if we have permissions to write to this file
fs.accessSync(hubMetaDataPath, fs.constants.W_OK);
if (!fs.existsSync(hubMetaDataPath)) {
const metadata = {
productName: `Unity ${this.version.version.toString()}`,
entitlements: [],
releaseStream: '',
isLTS: null
};
Object.keys(metadata).forEach(key => {
if (key === 'productName') {
return;
}
newMetadata[key] = metadata[key];
});
fs.writeFileSync(hubMetaDataPath, JSON.stringify(newMetadata), { encoding: 'utf-8' });
fs.writeFileSync(hubMetaDataPath, JSON.stringify(metadata), { encoding: 'utf-8' });
}
else {
const metadataContent = fs.readFileSync(hubMetaDataPath, { encoding: 'utf-8' });
const metadata = JSON.parse(metadataContent);
if (!metadata.productName) {
// projectName must be the first property
const newMetadata = {
productName: `Unity ${this.version.version.toString()}`
};
Object.keys(metadata).forEach(key => {
if (key === 'productName') {
return;
}
newMetadata[key] = metadata[key];
});
fs.writeFileSync(hubMetaDataPath, JSON.stringify(newMetadata), { encoding: 'utf-8' });
}
}
}
catch (error) {
// ignore - we just won't be able to update the metadata file
this.logger.debug(`No write access to Unity editor root path: ${this.editorRootPath}`);
}
}
/**
* Get the full path to a Unity project template based on the provided template name or regex pattern.
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unity-setup",
"version": "2.1.1",
"version": "2.1.2",
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
"author": "RageAgainstThePixel",
"license": "MIT",
Expand All @@ -27,7 +27,7 @@
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"@actions/glob": "^0.5.0",
"@rage-against-the-pixel/unity-cli": "^1.5.1",
"@rage-against-the-pixel/unity-cli": "^1.5.3",
"semver": "^7.7.3",
"yaml": "^2.8.1"
},
Expand All @@ -44,4 +44,4 @@
"watch": "ncc build src/index.ts -o dist --source-map --license licenses.txt --watch",
"clean": "npm install && shx rm -rf dist/ out/ node_modules/ && npm ci"
}
}
}
Loading