@bobfrankston/gcards 0.1.6 → 0.1.7

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/gcards.ts +18 -4
  2. package/package.json +1 -1
package/gcards.ts CHANGED
@@ -25,12 +25,19 @@ function ts(): string {
25
25
  }
26
26
 
27
27
  let escapePressed = false;
28
+ let abortController: AbortController | null = null;
28
29
 
29
30
  function setupEscapeHandler(): void {
31
+ // Create new abort controller for this operation
32
+ abortController = new AbortController();
33
+
30
34
  // Handle Ctrl+C via SIGINT (works without raw mode)
31
35
  process.on('SIGINT', () => {
32
36
  escapePressed = true;
33
- console.log('\n\nCtrl+C pressed - stopping after current operation...');
37
+ if (abortController) {
38
+ abortController.abort();
39
+ }
40
+ console.log('\n\nCtrl+C pressed - aborting...');
34
41
  });
35
42
 
36
43
  // Handle ESC key via raw mode (optional, for graceful stop)
@@ -40,10 +47,16 @@ function setupEscapeHandler(): void {
40
47
  process.stdin.on('data', (key) => {
41
48
  if (key[0] === 27) { // ESC key
42
49
  escapePressed = true;
43
- console.log('\n\nESC pressed - stopping after current operation...');
50
+ if (abortController) {
51
+ abortController.abort();
52
+ }
53
+ console.log('\n\nESC pressed - aborting...');
44
54
  } else if (key[0] === 3) { // Ctrl+C in raw mode
45
55
  escapePressed = true;
46
- console.log('\n\nCtrl+C pressed - stopping after current operation...');
56
+ if (abortController) {
57
+ abortController.abort();
58
+ }
59
+ console.log('\n\nCtrl+C pressed - aborting...');
47
60
  }
48
61
  });
49
62
  }
@@ -80,7 +93,8 @@ async function getAccessToken(user: string, writeAccess = false, forceRefresh =
80
93
  tokenFileName,
81
94
  credentialsKey: 'web',
82
95
  includeOfflineAccess: true,
83
- prompt: 'select_account' // Always show account picker for new auth
96
+ prompt: 'select_account', // Always show account picker for new auth
97
+ signal: abortController?.signal // Pass abort signal for immediate cancellation
84
98
  });
85
99
 
86
100
  if (!token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/gcards",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Google Contacts cleanup and management tool",
5
5
  "type": "module",
6
6
  "main": "gcards.ts",