chore: run eslint --fix

This commit is contained in:
CosminPerRam 2024-06-29 23:27:19 +03:00
parent 2c8fef316b
commit a5187f70f9
10 changed files with 61 additions and 62 deletions

View File

@ -80,10 +80,10 @@ export default class dayz extends valve {
state.raw.dlcEnabled = true
}
if (tag.includes('privHive')) {
state.raw.privateHive = true;
state.raw.privateHive = true
}
if (tag.includes('external')) {
state.raw.external = true;
state.raw.external = true
}
if (tag.includes(':')) {
state.raw.time = tag

View File

@ -17,13 +17,12 @@ if (argv._.length >= 1) {
const gamedig = new GameDig(options)
let protocolList = []
const protocolList = []
Object.keys(protocols).forEach((key) => protocolList.push(key))
const services = ['discord', 'beammpmaster', 'beammp', 'teamspeak2', 'teamspeak3']
const protocolListFiltered = protocolList.filter((protocol) => !services.includes(protocol))
const run = async () => {
for (const protocol of protocolListFiltered) {
try {

View File

@ -1,11 +1,11 @@
#!/usr/bin/env node
import { spawnSync } from "node:child_process";
import assert from "node:assert";
import { mkdirSync, copyFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import process from "node:process";
import { spawnSync } from 'node:child_process'
import assert from 'node:assert'
import { mkdirSync, copyFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import process from 'node:process'
// Generate a list of changes to "lib/games.js" where game IDs have been changed via the git history.
// Requires git to be installed.
@ -25,81 +25,81 @@ import process from "node:process";
const main = async (rootDir) => {
// Make sure CWD is the root of the repo
process.chdir(rootDir);
process.chdir(rootDir)
// Get list of commits that have modified lib/games.js
const gitLog = spawnSync(
"git",
'git',
[
"log",
"--follow",
"--format=%H",
"--diff-filter=M",
"--reverse",
"--",
"lib/games.js",
'log',
'--follow',
'--format=%H',
'--diff-filter=M',
'--reverse',
'--',
'lib/games.js'
],
{ encoding: "utf-8" }
);
{ encoding: 'utf-8' }
)
// Make a directory to store files in
mkdirSync("game_changes", { recursive: true });
mkdirSync('game_changes', { recursive: true })
const output = [];
const output = []
for (const commitHash of gitLog.stdout.split("\n")) {
if (commitHash.length === 0) continue;
for (const commitHash of gitLog.stdout.split('\n')) {
if (commitHash.length === 0) continue
// Checkout lib/games.js before the commit that changed it
assert(
spawnSync("git", ["checkout", `${commitHash}^1`, "--", "lib/games.js"])
spawnSync('git', ['checkout', `${commitHash}^1`, '--', 'lib/games.js'])
.status === 0
);
)
// We have to copy each state of the file to its own file because node caches imports
const beforeName = `game_changes/${commitHash}-before.js`;
copyFileSync("lib/games.js", beforeName);
const beforeName = `game_changes/${commitHash}-before.js`
copyFileSync('lib/games.js', beforeName)
const before = await import(path.join("../", beforeName));
const before = await import(path.join('../', beforeName))
// Checkout lib/games.js after the commit that changed it
assert(
spawnSync("git", ["checkout", `${commitHash}`, "--", "lib/games.js"])
spawnSync('git', ['checkout', `${commitHash}`, '--', 'lib/games.js'])
.status === 0
);
)
const afterName = `game_changes/${commitHash}-after.js`;
copyFileSync("lib/games.js", afterName);
const afterName = `game_changes/${commitHash}-after.js`
copyFileSync('lib/games.js', afterName)
const after = await import(path.join("../", afterName));
const after = await import(path.join('../', afterName))
// Find game IDs that were removed and added
let removed = Object.keys(before.games).filter(
(key) => !(key in after.games)
);
)
let added = Object.keys(after.games).filter(
(key) => !(key in before.games)
);
)
const changes = [];
const changes = []
for (const rm of removed) {
for (const add of added) {
const beforeGame = before.games[rm];
const afterGame = after.games[add];
const beforeGame = before.games[rm]
const afterGame = after.games[add]
// Modify game names to ignore case, spaces, and punctuation
const beforeName = beforeGame.name.toLowerCase().replace(/[^a-z]/g, "");
const afterName = afterGame.name.toLowerCase().replace(/[^a-z]/g, "");
const beforeName = beforeGame.name.toLowerCase().replace(/[^a-z]/g, '')
const afterName = afterGame.name.toLowerCase().replace(/[^a-z]/g, '')
if (
beforeGame.options.protocol === afterGame.options.protocol &&
(beforeName.includes(afterName) || afterName.includes(beforeName))
) {
changes.push([rm, add]);
removed = removed.filter((r) => r !== rm);
added = added.filter((a) => a !== add);
break;
changes.push([rm, add])
removed = removed.filter((r) => r !== rm)
added = added.filter((a) => a !== add)
break
}
}
}
@ -108,18 +108,18 @@ const main = async (rootDir) => {
hash: commitHash,
changes,
removed,
added,
});
added
})
}
// Reset the contents of lib/games.js
spawnSync("git", ["checkout", "--", "lib/games.js"]);
spawnSync('git', ['checkout', '--', 'lib/games.js'])
return output;
};
return output
}
main(
// Get the root of the repo:
// dir of bin/find-id-changes.js -> /../
path.join(path.dirname(fileURLToPath(import.meta.url)), "..")
).then((o) => console.log(JSON.stringify(o)), console.error);
path.join(path.dirname(fileURLToPath(import.meta.url)), '..')
).then((o) => console.log(JSON.stringify(o)), console.error)