Skip to content

Commit

Permalink
Fix .tgs.yml scripts setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberboss committed Jun 18, 2023
1 parent 2cf2e2d commit 5d60a6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions src/components/views/Instance/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,24 +445,25 @@ class InstanceCreate extends React.Component<IProps, IState> {
}

const isWindows = this.context.serverInfo.windowsHost;
const scripts =
(isWindows ? yml.windows_scripts : yml.linux_scripts) ?? new Map<string, string>();
const scripts = (isWindows ? yml.windows_scripts : yml.linux_scripts) ?? {};
const secLevel = getTGSYmlSecurity(yml) ?? DreamDaemonSecurity.Safe;
try {
const scriptData = new Map<string, string>();
if (scripts.size > 0) {
for (const scriptKvp of scripts) {
const scriptKeys = Object.keys(scripts);
if (scriptKeys.length > 0) {
for (const scriptName of scriptKeys) {
const scriptPath = scripts[scriptName];
this.pushStage(
<FormattedMessage
id="view.instance.create.quick.stage.download_scripts"
values={{ script: scriptKvp[1] }}
values={{ script: scriptName }}
/>
);

const scriptResponse = await GithubClient.getFile(
this.state.repoOwner,
this.state.repoName,
scriptKvp[1]
scriptPath
);

if (scriptResponse.code === StatusCode.ERROR) {
Expand All @@ -473,7 +474,7 @@ class InstanceCreate extends React.Component<IProps, IState> {
return;
}

scriptData.set(scriptKvp[0], scriptResponse.payload);
scriptData.set(scriptName, scriptResponse.payload);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/ITGSYml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default interface ITGSYml {
version: number;
byond?: string;
static_files?: IStaticFile[];
linux_scripts?: Map<string, string>;
windows_scripts?: Map<string, string>;
linux_scripts?: { [index: string]: string };
windows_scripts?: { [index: string]: string };
security?: string;
}

0 comments on commit 5d60a6e

Please sign in to comment.