apphud-mcp 0.1.1 → 0.1.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/src/cli.js +15 -3
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { access, writeFile } from "node:fs/promises";
|
|
3
|
-
import { constants } from "node:fs";
|
|
3
|
+
import { constants, realpathSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { buildExampleSimpleConfig } from "./config/env.js";
|
|
@@ -85,8 +85,20 @@ async function main() {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
if (
|
|
88
|
+
function isDirectRun() {
|
|
89
|
+
if (!process.argv[1]) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
93
|
+
try {
|
|
94
|
+
// npm links bin to a symlink in node_modules/.bin; resolve it to actual file.
|
|
95
|
+
return realpathSync(process.argv[1]) === currentFile;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return path.resolve(process.argv[1]) === currentFile;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (isDirectRun()) {
|
|
90
102
|
main().catch((error) => {
|
|
91
103
|
console.error(error instanceof Error ? error.message : String(error));
|
|
92
104
|
process.exitCode = 1;
|