mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 15:27:28 +00:00
chore(ci): format
This commit is contained in:
parent
102e48914b
commit
7985fb2613
6 changed files with 42 additions and 31 deletions
37
.github/workflows/scripts/node-badge.mjs
vendored
37
.github/workflows/scripts/node-badge.mjs
vendored
|
|
@ -9,10 +9,10 @@ import { closeSync, openSync, writeSync } from "node:fs";
|
|||
import { spawnSync } from "node:child_process";
|
||||
|
||||
const setOutput = (key, value) => {
|
||||
const file = openSync(process.env.GITHUB_OUTPUT, "a");
|
||||
writeSync(file, `${key}=${value}\n`);
|
||||
closeSync(file);
|
||||
}
|
||||
const file = openSync(process.env.GITHUB_OUTPUT, "a");
|
||||
writeSync(file, `${key}=${value}\n`);
|
||||
closeSync(file);
|
||||
};
|
||||
|
||||
// Get node IDs
|
||||
// NOTE: Here we directly import from games to avoid loading
|
||||
|
|
@ -25,28 +25,39 @@ const node_total = node_ids.size;
|
|||
|
||||
// Get rust IDs
|
||||
|
||||
const command = spawnSync("cargo", ["run", "-p", "gamedig", "--example", "generic"]);
|
||||
const command = spawnSync("cargo", [
|
||||
"run",
|
||||
"-p",
|
||||
"gamedig",
|
||||
"--example",
|
||||
"generic",
|
||||
]);
|
||||
|
||||
if (command.status !== 0) {
|
||||
console.error(command.stderr.toString("utf8"));
|
||||
process.exit(1);
|
||||
console.error(command.stderr.toString("utf8"));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const rust_ids_pretty = command.stdout.toString("utf8");
|
||||
const rust_ids = new Set(rust_ids_pretty.split("\n").map(line => line.split("\t")[0]).filter(id => id.length > 0));
|
||||
const rust_ids = new Set(
|
||||
rust_ids_pretty
|
||||
.split("\n")
|
||||
.map((line) => line.split("\t")[0])
|
||||
.filter((id) => id.length > 0)
|
||||
);
|
||||
|
||||
// Detect missing node IDs
|
||||
|
||||
for (const id of rust_ids) {
|
||||
if (node_ids.delete(id)) {
|
||||
rust_ids.delete(id);
|
||||
}
|
||||
if (node_ids.delete(id)) {
|
||||
rust_ids.delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Node remains", node_ids);
|
||||
console.log("Rust remains", rust_ids);
|
||||
|
||||
const percent = 1 - (node_ids.size / node_total);
|
||||
const percent = 1 - node_ids.size / node_total;
|
||||
|
||||
// Output percent to 2 decimal places
|
||||
setOutput("percent", Math.round(percent*10000)/100);
|
||||
setOutput("percent", Math.round(percent * 10000) / 100);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue