Skip to content

Commit fbc651d

Browse files
committed
feat: add bin script
1 parent 0f5aa01 commit fbc651d

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

package-lock.json

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"description": "",
55
"main": "./lib/index.js",
6+
"bin": "./lib/bin.js",
67
"type": "module",
78
"private": false,
89
"publishConfig": {
@@ -87,7 +88,8 @@
8788
"@typescript-eslint/no-misused-promises": 1,
8889
"@typescript-eslint/no-unused-vars": 0,
8990
"node/no-missing-import": 0,
90-
"no-case-declarations": 0
91+
"no-case-declarations": 0,
92+
"node/shebang": 0
9193
}
9294
},
9395
"engines": {

src/bin.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env node
2+
import { fileURLToPath } from "url";
3+
import { realpathSync } from "fs";
4+
import process from "process";
5+
import yargs, { CommandModule } from "yargs";
6+
import { hideBin } from "yargs/helpers";
7+
8+
if (realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
9+
main().catch((error) => {
10+
throw error;
11+
});
12+
}
13+
14+
async function main() {
15+
const argv = await yargs(hideBin(process.argv))
16+
.command(RequestUcanCommand())
17+
.help().argv;
18+
}
19+
20+
function RequestUcanCommand(): CommandModule {
21+
return {
22+
command: "request-ucan",
23+
describe: "request a UCAN to invoke the name service",
24+
handler: async () => {
25+
console.log("RequestUcanCommand");
26+
},
27+
};
28+
}

0 commit comments

Comments
 (0)