Skip to content

Commit

Permalink
style: better logging for auto-start
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishqmanuja committed Jan 11, 2024
1 parent 70a8c10 commit 5dd7dd1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/helpers/valorant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { exec } from "child_process";
import { readFile } from "fs/promises";
import { join } from "path";

import { LOGGER } from "~/logger";
import { isProcessRunning } from "~/utils/process";

import { TAGS } from "./tags";
Expand All @@ -15,6 +16,8 @@ const RIOT_CLIENT_INSTALLS_FILE_PATH = join(
"RiotClientInstalls.json",
);

const logger = LOGGER.forModule("Helpers");

export async function getRiotClientPath(): Promise<string> {
return readFile(RIOT_CLIENT_INSTALLS_FILE_PATH, { encoding: "utf-8" })
.then(JSON.parse)
Expand All @@ -31,10 +34,16 @@ export async function autoStartValorant() {
const isValorantRunning = await isProcessRunning("valorant.exe");

if (isValorantRunning) {
console.log(TAGS.info, "Valorant is already running\n");
logger.info("Valorant is already running");
return;
}

console.log(TAGS.info, "Starting Valorant\n");
return getRiotClientPath().then(launchValorant);
return getRiotClientPath()
.then(launchValorant)
.then(() => {
logger.info("Auto-started Valorant");
})
.catch(e => {
logger.error("Failed to auto-start Valorant", e);
});
}

0 comments on commit 5dd7dd1

Please sign in to comment.