@oomfware/cgr 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.mjs +10 -1
- package/package.json +1 -1
- package/src/commands/clean.ts +10 -1
- package/src/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -305,14 +305,22 @@ const listCachedRepos = () => {
|
|
|
305
305
|
/**
|
|
306
306
|
* prompts the user for confirmation.
|
|
307
307
|
* @param msg the prompt message
|
|
308
|
-
* @returns promise that resolves to true if confirmed
|
|
308
|
+
* @returns promise that resolves to true if confirmed, or exits on interrupt
|
|
309
309
|
*/
|
|
310
310
|
const confirm = (msg) => new Promise((resolve) => {
|
|
311
|
+
let answered = false;
|
|
311
312
|
const rl = createInterface({
|
|
312
313
|
input: process.stdin,
|
|
313
314
|
output: process.stdout
|
|
314
315
|
});
|
|
316
|
+
rl.on("close", () => {
|
|
317
|
+
if (!answered) {
|
|
318
|
+
console.log();
|
|
319
|
+
process.exit(130);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
315
322
|
rl.question(`${msg} [y/N] `, (answer) => {
|
|
323
|
+
answered = true;
|
|
316
324
|
rl.close();
|
|
317
325
|
resolve(answer.toLowerCase() === "y");
|
|
318
326
|
});
|
|
@@ -372,6 +380,7 @@ const handler = async (args) => {
|
|
|
372
380
|
//#endregion
|
|
373
381
|
//#region src/index.ts
|
|
374
382
|
const result = run(or(command("ask", schema$1, { description: message`ask a question about a repository` }), command("clean", schema, { description: message`remove cached repositories` })), {
|
|
383
|
+
programName: "cgr",
|
|
375
384
|
help: "both",
|
|
376
385
|
version: {
|
|
377
386
|
value: "0.1.0",
|
package/package.json
CHANGED
package/src/commands/clean.ts
CHANGED
|
@@ -113,15 +113,24 @@ const listCachedRepos = (): {
|
|
|
113
113
|
/**
|
|
114
114
|
* prompts the user for confirmation.
|
|
115
115
|
* @param msg the prompt message
|
|
116
|
-
* @returns promise that resolves to true if confirmed
|
|
116
|
+
* @returns promise that resolves to true if confirmed, or exits on interrupt
|
|
117
117
|
*/
|
|
118
118
|
const confirm = (msg: string): Promise<boolean> =>
|
|
119
119
|
new Promise((resolve) => {
|
|
120
|
+
let answered = false;
|
|
120
121
|
const rl = createInterface({
|
|
121
122
|
input: process.stdin,
|
|
122
123
|
output: process.stdout,
|
|
123
124
|
});
|
|
125
|
+
rl.on('close', () => {
|
|
126
|
+
if (!answered) {
|
|
127
|
+
// handle Ctrl+C or stream close
|
|
128
|
+
console.log();
|
|
129
|
+
process.exit(130);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
124
132
|
rl.question(`${msg} [y/N] `, (answer) => {
|
|
133
|
+
answered = true;
|
|
125
134
|
rl.close();
|
|
126
135
|
resolve(answer.toLowerCase() === 'y');
|
|
127
136
|
});
|