Skip to content

Commit

Permalink
feat(ksuid): add CLI wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Feb 7, 2023
1 parent 1f39ec8 commit 36fdc08
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/ksuid/bin/ksuid
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# https://stackoverflow.com/a/246128/294515
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"

/usr/bin/env node "$DIR/../cli.js" "$DIR" "$@"
1 change: 1 addition & 0 deletions packages/ksuid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"type": "module",
"module": "./index.js",
"typings": "./index.d.ts",
"bin": "bin/ksuid",
"sideEffects": false,
"repository": {
"type": "git",
Expand Down
5 changes: 5 additions & 0 deletions packages/ksuid/src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defKSUID32 } from "./ksuid32.js";

const bytes = parseInt(process.argv[3] || "16");

process.stdout.write(defKSUID32({ bytes }).next() + "\n");
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4165,6 +4165,8 @@ __metadata:
tools: "workspace:^"
typedoc: ^0.23.24
typescript: ^4.9.5
bin:
ksuid: bin/ksuid
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 36fdc08

Please sign in to comment.