ccusage-tracker 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.
Files changed (2) hide show
  1. package/dist/index.js +24 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -111,14 +111,23 @@ function isHookInstalled() {
111
111
  }
112
112
 
113
113
  // src/commands/setup.ts
114
- function defaultPrompt(question) {
115
- const rl = createInterface({ input: process.stdin, output: process.stdout });
116
- return new Promise((resolve) => {
117
- rl.question(question, (answer) => {
118
- rl.close();
119
- resolve(answer.trim());
120
- });
121
- });
114
+ var sharedRl = null;
115
+ var lineIterator = null;
116
+ async function defaultPrompt(question) {
117
+ if (!sharedRl || !lineIterator) {
118
+ sharedRl = createInterface({ input: process.stdin, output: process.stdout });
119
+ lineIterator = sharedRl[Symbol.asyncIterator]();
120
+ }
121
+ process.stdout.write(question);
122
+ const { value, done } = await lineIterator.next();
123
+ return done ? "" : value.trim();
124
+ }
125
+ function closeSharedPrompt() {
126
+ if (sharedRl) {
127
+ sharedRl.close();
128
+ sharedRl = null;
129
+ lineIterator = null;
130
+ }
122
131
  }
123
132
  async function defaultCheckServer(serverUrl) {
124
133
  try {
@@ -160,6 +169,13 @@ var defaultDeps = {
160
169
  };
161
170
  async function setupCommand(overrides) {
162
171
  const deps = { ...defaultDeps, ...overrides };
172
+ try {
173
+ await runSetup(deps);
174
+ } finally {
175
+ closeSharedPrompt();
176
+ }
177
+ }
178
+ async function runSetup(deps) {
163
179
  deps.log(`ccusage-tracker setup
164
180
  `);
165
181
  const name = await deps.prompt("Your name: ");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccusage-tracker",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI for ccusage-tracker — install Claude Code SessionStart/SessionEnd hooks to report token usage to a self-hosted team tracker.",
5
5
  "type": "module",
6
6
  "bin": {