Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #65 from CreatorsTF/fix/config-file-not-being-created
Browse files Browse the repository at this point in the history
  • Loading branch information
jota11 authored Aug 21, 2021
2 parents 4922a63 + 2a50b09 commit 7c891dd
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; connect-src https://api.github.com/repos/ampersoftware/Creators.TF-Community-Launcher/releases/latest https://api.github.com/repos/CreatorsTF/Creators.TF-Community-Launcher/releases/latest https://creators.tf https://fastdl.creators.tf 'self'; img-src 'self' https://creators.tf https://fastdl.creators.tf; style-src 'self'; base-uri 'self'; form-action 'self'; font-src 'self';">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; connect-src https://api.github.com/repos/CreatorsTF/Creators.TF-Community-Launcher/releases/latest https://creators.tf https://fastdl.creators.tf 'self'; img-src 'self' https://creators.tf https://fastdl.creators.tf; style-src 'self'; base-uri 'self'; form-action 'self'; font-src 'self';">
<title>Creators.TF Launcher - Alpha Version</title>
<link rel="stylesheet" href="node_modules/@mdi/font/css/materialdesignicons.min.css">
<link rel="stylesheet" href="styles/style.css">
Expand Down
2 changes: 1 addition & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ log.transports.file.fileName = "main.log";
log.transports.file.maxSize = 10485760;
log.transports.file.getFile();

const majorErrorMessageEnd = "\nIf this error persists, please report it on our GitHub page by making a new 'Issue'.\nVisit creators.tf/launcher for more info.\nYou can also report if via our Discord.";
const majorErrorMessageEnd = "\nIf this error persists, please report it on our GitHub page by creating a new 'Issue'.\nVisit creators.tf/launcher for more info.";

class Main {
public static mainWindow: BrowserWindow;
Expand Down
23 changes: 6 additions & 17 deletions modules/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Config {
//Try to populate the default values of the steam directory and tf2 directory automatically.
this.config.steam_directory = await Config.GetSteamDirectory();

log.log(`Auto locater for the users steam directory returned '${this.config.steam_directory}'`);
log.log(`Auto locater for the users steam directory returned "${this.config.steam_directory}"`);

if (this.config.steam_directory != "") {
//Try to find the users tf2 directory automatically.
Expand Down Expand Up @@ -102,7 +102,6 @@ class Config {

public static async GetConfigFullPath(): Promise<string> {
const _path = (process.env.APPDATA || (process.platform == "darwin" ? process.env.HOME + "/Library/Preferences" : process.env.HOME + "/.local/share")) + "/creators-tf-launcher";

await FsExtensions.ensureDirectoryExists(_path);

const configName = "config.json";
Expand All @@ -117,13 +116,12 @@ class Config {
/**
* Gets first existing path in an array of strings
* @param {string[]} steamPaths An array of directory paths
* @param {string} pathPrefix A path to add before each path in steamPaths before checking
* @returns First existing path in steamPaths or null if none of the paths exist, with prefix added
*/

async function getExistingPath(steamPaths: Array<string>, pathPrefix: string): Promise<string> {
async function getExistingPath(steamPaths: Array<string>): Promise<string> {
for (let steamPath of steamPaths) {
steamPath = path.join(pathPrefix, steamPath);
steamPath = path.join(steamPath);
if (await FsExtensions.pathExists(steamPath)) {
return steamPath;
}
Expand All @@ -136,24 +134,15 @@ class Config {
//We check the most likely install paths.
if (os.platform() == "win32") {
const steamPaths = ["C:/Program Files (x86)/Steam", "C:/Program Files/Steam"];
//@ts-ignore
basedir = await getExistingPath(steamPaths);
}
else if (os.platform() == "linux" || "freebsd" || "openbsd") {
//Linux solution is untested
const homedir = process.env.HOME;
const steamPaths = [
{
"paths": [".steam/steam"],
"prefix": homedir
},
{
"paths": [".local/share/steam"],
"prefix": ""
}
];
const steamPaths = [".steam/steam", ".local/share/steam"];
for (const pathGroup of steamPaths) {
basedir = await getExistingPath(pathGroup["paths"], pathGroup["prefix"]);
let existingPath = await getExistingPath(pathGroup["paths"]);
basedir = path.join(homedir, existingPath);
if (basedir != "") {
break;
}
Expand Down
1 change: 0 additions & 1 deletion modules/mod_list_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Utilities from "./utilities";
//More than one allows fallbacks.
const modListURLs = [
"https://fastdl.creators.tf/launcher/mods.json",
"https://raw.githubusercontent.com/ampersoftware/Creators.TF-Community-Launcher/master/internal/mods.json",
"https://raw.githubusercontent.com/CreatorsTF/Creators.TF-Community-Launcher/master/internal/mods.json"
];

Expand Down
2 changes: 1 addition & 1 deletion patchnotes-page/patchnotes.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; connect-src 'self' https://raw.githubusercontent.com/ampersoftware/Creators.TF-Community-Launcher/master/changelog.md https://raw.githubusercontent.com/CreatorsTF/Creators.TF-Community-Launcher/master/changelog.md; img-src 'self'; style-src 'self'; base-uri 'self'; form-action 'self'; font-src 'self';">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; connect-src 'self' https://raw.githubusercontent.com/CreatorsTF/Creators.TF-Community-Launcher/master/changelog.md; img-src 'self'; style-src 'self'; base-uri 'self'; form-action 'self'; font-src 'self';">
<link rel="stylesheet" href="../styles/patchnotes.css">
<title>Creators.TF Launcher - Alpha Version - Patch Notes</title>
</head>
Expand Down
2 changes: 1 addition & 1 deletion patchnotes-page/patchnotespage-preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ marked.setOptions({
});

window.addEventListener("DOMContentLoaded", () => {
fetch("https://raw.githubusercontent.com/ampersoftware/Creators.TF-Community-Launcher/master/changelog.md").then(async (res) => {
fetch("https://raw.githubusercontent.com/CreatorsTF/Creators.TF-Community-Launcher/master/changelog.md").then(async (res) => {
if (res.status === 200) {
res.text().then((data) => {
document.getElementById("patchnotes").innerHTML = marked(data);
Expand Down
2 changes: 1 addition & 1 deletion preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ipcRenderer.on("ShowMods", (event, data) => {
const launcherVersionBox = document.getElementById("launcher-version");
const config: any = fs.readFileSync(path.join(__dirname, "package.json"));
const currentClientVersion: number = JSON.parse(config).version;
fetch("https://api.github.com/repos/ampersoftware/Creators.TF-Community-Launcher/releases/latest").then((res) => {
fetch("https://api.github.com/repos/CreatorsTF/Creators.TF-Community-Launcher/releases/latest").then((res) => {
if (res.status === 200) {
res.json().then((data) => {
const version = data.tag_name;
Expand Down

0 comments on commit 7c891dd

Please sign in to comment.