Skip to content

Commit

Permalink
fix crash on startup
Browse files Browse the repository at this point in the history
TychoTheTaco committed Apr 20, 2022
1 parent 94cf9dc commit c290449
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ on:
workflow_dispatch:
push:
branches:
- master
- dev
jobs:
build-docker:
name: Build and release Docker image
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twitch_drops_bot",
"version": "1.0.0",
"version": "1.0.1",
"description": "A Node.js bot for automatically collecting Twitch drops.",
"type": "module",
"repository": {
12 changes: 9 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import path from "node:path";
import {fileURLToPath} from "node:url";

import axios from "axios";
import {render} from "ink";
@@ -27,8 +28,13 @@ import {compareVersionString} from "./utils.js";
puppeteer.use(StealthPlugin());

// Load version number from package.json
const pkg = JSON.parse(fs.readFileSync("package.json", {encoding: "utf-8"}));
const VERSION = pkg["version"] ?? "unknown";
let VERSION = "unknown";
try {
const pkg = JSON.parse(fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "package.json"), {encoding: "utf-8"}));
VERSION = pkg["version"] ?? "unknown";
} catch (error) {
logger.error("Cannot read version");
}

function onBrowserOrPageClosed() {
logger.info('Browser was disconnected or tab was closed! Exiting...');

0 comments on commit c290449

Please sign in to comment.