@starfetch-js/cli 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/dist/index.d.ts +2 -1
- package/dist/index.js +12 -4
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ type RunCliOptions = {
|
|
|
17
17
|
//#region packages/cli/src/index.d.ts
|
|
18
18
|
declare function helpText(): string;
|
|
19
19
|
declare function runCli(argv?: any, options?: RunCliOptions): Promise<number>;
|
|
20
|
+
declare function isCliEntrypoint(moduleUrl: string, argvPath: string | undefined): boolean;
|
|
20
21
|
//#endregion
|
|
21
|
-
export { helpText, runCli };
|
|
22
|
+
export { helpText, isCliEntrypoint, runCli };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import fs, { realpathSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
3
4
|
import { EventEmitter } from "node:events";
|
|
4
5
|
import childProcess from "node:child_process";
|
|
5
6
|
import path, { basename } from "node:path";
|
|
6
|
-
import fs from "node:fs";
|
|
7
7
|
import process$1 from "node:process";
|
|
8
8
|
import { stripVTControlCharacters } from "node:util";
|
|
9
9
|
import { readFile, writeFile } from "node:fs/promises";
|
|
@@ -7745,7 +7745,15 @@ async function runCli(argv = process.argv.slice(2), options = {}) {
|
|
|
7745
7745
|
return 1;
|
|
7746
7746
|
}
|
|
7747
7747
|
}
|
|
7748
|
-
if (
|
|
7748
|
+
if (isCliEntrypoint(import.meta.url, process.argv[1])) process.exitCode = await runCli(process.argv.slice(2), { stdin: process.stdin });
|
|
7749
|
+
function isCliEntrypoint(moduleUrl, argvPath) {
|
|
7750
|
+
if (argvPath === void 0) return false;
|
|
7751
|
+
try {
|
|
7752
|
+
return realpathSync(fileURLToPath(moduleUrl)) === realpathSync(argvPath);
|
|
7753
|
+
} catch {
|
|
7754
|
+
return false;
|
|
7755
|
+
}
|
|
7756
|
+
}
|
|
7749
7757
|
function createProgram(options) {
|
|
7750
7758
|
const stdout = options.stdout ?? process.stdout;
|
|
7751
7759
|
const stderr = options.stderr ?? process.stderr;
|
|
@@ -7768,4 +7776,4 @@ function formatError(error) {
|
|
|
7768
7776
|
return "Unknown CLI error";
|
|
7769
7777
|
}
|
|
7770
7778
|
//#endregion
|
|
7771
|
-
export { helpText, runCli };
|
|
7779
|
+
export { helpText, isCliEntrypoint, runCli };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starfetch-js/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Command-line interface for Starfetch.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"test": "vitest run"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@starfetch-js/core": "0.1.
|
|
46
|
-
"@starfetch-js/skill": "0.1.
|
|
45
|
+
"@starfetch-js/core": "0.1.1",
|
|
46
|
+
"@starfetch-js/skill": "0.1.1",
|
|
47
47
|
"commander": "15.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|