feat: add Screeps console monitoring with configurable error handling and shard support (#84)
Reviewed-on: #84
This commit was merged in pull request #84.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { glob } from "glob";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import fs from "fs";
|
||||
|
||||
async function test() {
|
||||
const tempDir = await fs.promises.mkdtemp(
|
||||
path.join(os.tmpdir(), "glob-test-"),
|
||||
);
|
||||
const file = path.join(tempDir, "test.js");
|
||||
await fs.promises.writeFile(file, "test");
|
||||
|
||||
const pattern = "*.js";
|
||||
const globPattern = path.join(tempDir, pattern);
|
||||
console.log("globPattern:", globPattern);
|
||||
|
||||
const files = await glob(globPattern);
|
||||
console.log("found files:", files);
|
||||
|
||||
// Fix for windows
|
||||
const fixedPattern = globPattern.replace(/\\/g, "/");
|
||||
console.log("fixedPattern:", fixedPattern);
|
||||
const fixedFiles = await glob(fixedPattern);
|
||||
console.log("found fixed files:", fixedFiles);
|
||||
|
||||
await fs.promises.rm(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
test();
|
||||
@@ -0,0 +1,12 @@
|
||||
function detectTraceback(errorText) {
|
||||
if (!errorText) return false;
|
||||
return /^\s{4}at /m.test(errorText);
|
||||
}
|
||||
|
||||
const encodedTraceback =
|
||||
"Error: ReferenceError: a is not defined%0A at eval (eval at <anonymous> (_console1778948572008_0:1:46), <anonymous>:1:1)%0A at _console1778948572008_0:1:46%0A at _console1778948572008_0:1:60%0A at exports.evalCode (<runtime>:15347:63)%0A at exports.run (<runtime>:20876:41)%0A";
|
||||
|
||||
console.log("Encoded match:", detectTraceback(encodedTraceback));
|
||||
|
||||
const decodedTraceback = decodeURIComponent(encodedTraceback);
|
||||
console.log("Decoded match:", detectTraceback(decodedTraceback));
|
||||
Reference in New Issue
Block a user