lockage 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +15 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -670,9 +670,22 @@ async function main() {
|
|
|
670
670
|
// Startup log to stderr only (stdout is reserved for JSON-RPC, so do not write there)
|
|
671
671
|
process.stderr.write(`[lockage] ready (db=${DB_PATH}, toolsets=${['core', ...toolsets].join(',')})\n`);
|
|
672
672
|
}
|
|
673
|
-
// Start only when run as the entry point (do not start when imported from tests)
|
|
673
|
+
// Start only when run as the entry point (do not start when imported from tests).
|
|
674
|
+
// Compare realpath-resolved paths: when launched via a bin symlink (npx / a Node version
|
|
675
|
+
// manager's bin), process.argv[1] is the symlink while import.meta.url resolves to the real
|
|
676
|
+
// file, so a raw string compare never matches and the server would silently never start.
|
|
674
677
|
import { fileURLToPath } from 'node:url';
|
|
675
|
-
|
|
678
|
+
import { realpathSync } from 'node:fs';
|
|
679
|
+
const resolveReal = (p) => {
|
|
680
|
+
try {
|
|
681
|
+
return realpathSync(p);
|
|
682
|
+
}
|
|
683
|
+
catch {
|
|
684
|
+
return p;
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
if (process.argv[1] &&
|
|
688
|
+
resolveReal(fileURLToPath(import.meta.url)) === resolveReal(process.argv[1])) {
|
|
676
689
|
const fatal = (e) => {
|
|
677
690
|
process.stderr.write(`[lockage] fatal: ${e?.stack ?? e}\n`);
|
|
678
691
|
process.exit(1);
|