shipmail-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/cli.d.ts +2 -1
- package/dist/cli.js +9 -3
- package/package.json +1 -1
package/dist/cli.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ type RunCliOptions = {
|
|
|
10
10
|
readonly fetch?: typeof fetch | undefined;
|
|
11
11
|
};
|
|
12
12
|
declare function runCli(argv: readonly string[], options?: RunCliOptions): Promise<number>;
|
|
13
|
+
declare function isMainModule(moduleUrl?: string, argvPath?: string | undefined): boolean;
|
|
13
14
|
|
|
14
|
-
export { runCli };
|
|
15
|
+
export { isMainModule, runCli };
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
+
import { realpathSync } from "fs";
|
|
4
5
|
import { readFile, writeFile } from "fs/promises";
|
|
5
6
|
import { env as processEnv, exit, stderr, stdout } from "process";
|
|
6
|
-
import {
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
7
8
|
import {
|
|
8
9
|
ShipMailClient,
|
|
9
10
|
ShipMailError,
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
} from "shipmail";
|
|
12
13
|
|
|
13
14
|
// src/version.ts
|
|
14
|
-
var VERSION = "0.1.
|
|
15
|
+
var VERSION = "0.1.1";
|
|
15
16
|
|
|
16
17
|
// src/cli.ts
|
|
17
18
|
var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
|
|
@@ -643,9 +644,14 @@ async function main() {
|
|
|
643
644
|
const code = await runCli(process.argv.slice(2));
|
|
644
645
|
exit(code);
|
|
645
646
|
}
|
|
646
|
-
|
|
647
|
+
function isMainModule(moduleUrl = import.meta.url, argvPath = process.argv[1]) {
|
|
648
|
+
if (!argvPath) return false;
|
|
649
|
+
return realpathSync(fileURLToPath(moduleUrl)) === realpathSync(argvPath);
|
|
650
|
+
}
|
|
651
|
+
if (isMainModule()) {
|
|
647
652
|
void main();
|
|
648
653
|
}
|
|
649
654
|
export {
|
|
655
|
+
isMainModule,
|
|
650
656
|
runCli
|
|
651
657
|
};
|