@plannotator/tot 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/cli.d.ts +1 -0
- package/dist/cli.js +18 -1
- package/package.json +1 -1
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
2
5
|
import { listCommand, loginCommand, publishCommand, removeCommand, updateCommand, } from "./commands.js";
|
|
3
6
|
import { Config } from "./config.js";
|
|
4
7
|
import { createHttpClient } from "./http.js";
|
|
@@ -97,8 +100,22 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
97
100
|
await publishCommand(cmd, cfg, deps);
|
|
98
101
|
return 0;
|
|
99
102
|
}
|
|
103
|
+
function realPathForEntrypoint(value) {
|
|
104
|
+
const absolute = path.resolve(value);
|
|
105
|
+
try {
|
|
106
|
+
return fs.realpathSync(absolute);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return absolute;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export function isCliEntrypoint(metaUrl, argv1 = process.argv[1]) {
|
|
113
|
+
if (argv1 === undefined)
|
|
114
|
+
return false;
|
|
115
|
+
return realPathForEntrypoint(fileURLToPath(metaUrl)) === realPathForEntrypoint(argv1);
|
|
116
|
+
}
|
|
100
117
|
// Only run when invoked as the CLI, not when imported (e.g. by tests).
|
|
101
|
-
if (import.meta.url
|
|
118
|
+
if (isCliEntrypoint(import.meta.url)) {
|
|
102
119
|
main().then((code) => process.exit(code), (err) => {
|
|
103
120
|
const msg = err instanceof Error ? err.message : String(err);
|
|
104
121
|
console.error("error:", msg);
|