diff --git a/src/indexer/bns-indexer.js b/src/indexer/bns-indexer.js index 20bb25c..4d4529e 100644 --- a/src/indexer/bns-indexer.js +++ b/src/indexer/bns-indexer.js @@ -19,6 +19,7 @@ import http from "node:http"; import { createHash } from "node:crypto"; import { readFileSync, writeFileSync, existsSync } from "node:fs"; +import { pathToFileURL } from "node:url"; import { WebSocketServer } from "ws"; // ---- config (env, with sane chipnet defaults) ---- @@ -240,6 +241,8 @@ async function main() { } // Only run the daemon when invoked directly (imports for tests stay side-effect free). -if (import.meta.url === `file://${process.argv[1]?.replace(/\\/g, "/")}`) { +// pathToFileURL is cross-platform: on Windows argv[1]="D:\..." yields file:///D:/... +// matching import.meta.url (the old `file://`+path check only matched on POSIX). +if (import.meta.url === pathToFileURL(process.argv[1] || "").href) { main().catch((e) => { console.error("fatal:", e.message); process.exit(1); }); }