mirror of
https://github.com/koichixD/uptime-kuma.git
synced 2026-09-04 09:13:21 +00:00
feat(gamedig): Update gamedig implementation to v5 (#4949)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
co-authored by
Frank Elsinga
parent
af342b68f5
commit
d096e2902c
@@ -2,30 +2,35 @@ const { log } = require("../../src/util");
|
||||
const { Settings } = require("../settings");
|
||||
const { sendInfo } = require("../client");
|
||||
const { checkLogin } = require("../util-server");
|
||||
const GameResolver = require("gamedig/lib/GameResolver");
|
||||
const { games } = require("gamedig");
|
||||
const { testChrome } = require("../monitor-types/real-browser-monitor-type");
|
||||
const fsAsync = require("fs").promises;
|
||||
const path = require("path");
|
||||
|
||||
let gameResolver = new GameResolver();
|
||||
let gameList = null;
|
||||
|
||||
/**
|
||||
* Get a game list via GameDig
|
||||
* @returns {object[]} list of games supported by GameDig
|
||||
* @returns {object} list of games supported by GameDig
|
||||
*/
|
||||
function getGameList() {
|
||||
if (gameList == null) {
|
||||
gameList = gameResolver._readGames().games.sort((a, b) => {
|
||||
if ( a.pretty < b.pretty ) {
|
||||
return -1;
|
||||
}
|
||||
if ( a.pretty > b.pretty ) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
let gameList = [];
|
||||
gameList = Object.keys(games).map(key => {
|
||||
const item = games[key];
|
||||
return {
|
||||
keys: [ key ],
|
||||
pretty: item.name,
|
||||
options: item.options,
|
||||
extra: item.extra || {}
|
||||
};
|
||||
});
|
||||
gameList.sort((a, b) => {
|
||||
if ( a.pretty < b.pretty ) {
|
||||
return -1;
|
||||
}
|
||||
if ( a.pretty > b.pretty ) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return gameList;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user