Skip to content

Commit c290449

Browse files
committed
fix crash on startup
1 parent 94cf9dc commit c290449

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

.github/workflows/docker.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
workflow_dispatch:
44
push:
55
branches:
6-
- master
6+
- dev
77
jobs:
88
build-docker:
99
name: Build and release Docker image

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twitch_drops_bot",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "A Node.js bot for automatically collecting Twitch drops.",
55
"type": "module",
66
"repository": {

src/index.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from 'fs';
2-
import path from 'path';
2+
import path from "node:path";
3+
import {fileURLToPath} from "node:url";
34

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

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

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

0 commit comments

Comments
 (0)