@wax0629/pi-manager 0.1.0 → 0.1.1
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/package.json +1 -1
- package/src/cli.mjs +10 -2
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -144,8 +144,16 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
144
144
|
return 0;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
if (
|
|
147
|
+
export function isCliEntrypoint(argv1 = process.argv[1], moduleUrl = import.meta.url) {
|
|
148
|
+
if (!argv1) return false;
|
|
149
|
+
try {
|
|
150
|
+
return fs.realpathSync(argv1) === fs.realpathSync(fileURLToPath(moduleUrl));
|
|
151
|
+
} catch {
|
|
152
|
+
return path.resolve(argv1) === fileURLToPath(moduleUrl);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (isCliEntrypoint()) {
|
|
149
157
|
main().catch((error) => {
|
|
150
158
|
console.error(error instanceof Error ? error.message : String(error));
|
|
151
159
|
process.exitCode = 1;
|