Skip to content

Commit

Permalink
refactor: Protect DataManager from unsupported nodejs version by movi…
Browse files Browse the repository at this point in the history
…ng check up
  • Loading branch information
3urobeat committed Jan 2, 2025
1 parent 222f17b commit 760dae1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Created Date: 2021-07-09 16:26:00
* Author: 3urobeat
*
* Last Modified: 2024-12-29 14:00:52
* Last Modified: 2025-01-02 10:38:34
* Modified By: 3urobeat
*
* Copyright (c) 2021 - 2024 3urobeat <https://github.com/3urobeat>
* Copyright (c) 2021 - 2025 3urobeat <https://github.com/3urobeat>
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Expand Down Expand Up @@ -197,6 +197,19 @@ Controller.prototype._start = async function() {
logger("", "---------------------------------------------------------", true, true);


// Check for unsupported node.js version (<16.0.0)
const versionarr = process.version.replace("v", "").split(".");

versionarr.forEach((e, i) => { if (e.length == 1 && parseInt(e) < 10) versionarr[i] = `0${e}`; }); // Put 0 in front of single digits

if (parseInt(versionarr.join("")) < 160000) {
logger("", "\n************************************************************************************\n", true);
logger("error", `This application requires at least node.js ${logger.colors.reset}v16.0.0${logger.colors.fgred} but you have ${logger.colors.reset}${process.version}${logger.colors.fgred} installed!\n Please update your node.js installation: ${logger.colors.reset} https://nodejs.org/`, true);
logger("", "\n************************************************************************************\n", true);
return this.stop();
}


/* ------------ Check internet connection: ------------ */
logger("info", "Checking if Steam is reachable...", false, true, logger.animation("loading"));

Expand Down Expand Up @@ -239,19 +252,6 @@ Controller.prototype._start = async function() {
}


// Check for unsupported node.js version (<16.0.0)
const versionarr = process.version.replace("v", "").split(".");

versionarr.forEach((e, i) => { if (e.length == 1 && parseInt(e) < 10) versionarr[i] = `0${e}`; }); // Put 0 in front of single digits

if (parseInt(versionarr.join("")) < 160000) {
logger("", "\n************************************************************************************\n", true);
logger("error", `This application requires at least node.js ${logger.colors.reset}v16.0.0${logger.colors.fgred} but you have ${logger.colors.reset}${process.version}${logger.colors.fgred} installed!\n Please update your node.js installation: ${logger.colors.reset} https://nodejs.org/`, true);
logger("", "\n************************************************************************************\n", true);
return this.stop();
}


/* ------------ Check imported data : ------------ */
let forceUpdate = false; // Provide forceUpdate var which the following helpers can modify to force a update

Expand Down
2 changes: 1 addition & 1 deletion src/data/fileStructure.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
{
"path": "src/controller/controller.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/controller/controller.js",
"checksum": "f9ebc14132ef60a47913dd0431c83282"
"checksum": "45b943499daa41b8e24e2c22b900a0ae"
},
{
"path": "src/controller/events/ready.js",
Expand Down

0 comments on commit 760dae1

Please sign in to comment.