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.
- package/dist/index.js +24 -8
- 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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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