|
1 | 1 | import { PackageManagerCompletion } from './package-manager-completion.js'; |
2 | 2 | import { readFileSync } from 'fs'; |
3 | 3 | import { execSync } from 'child_process'; |
| 4 | +import type { Complete } from '../src/t.js'; |
4 | 5 |
|
5 | 6 | // Helper functions for dynamic completions |
6 | 7 | function getPackageJsonScripts(): string[] { |
@@ -28,12 +29,12 @@ function getPackageJsonDependencies(): string[] { |
28 | 29 | } |
29 | 30 |
|
30 | 31 | // Common completion handlers |
31 | | -const scriptCompletion = async (complete: any) => { |
| 32 | +const scriptCompletion = async (complete: Complete) => { |
32 | 33 | const scripts = getPackageJsonScripts(); |
33 | 34 | scripts.forEach((script) => complete(script, `Run ${script} script`)); |
34 | 35 | }; |
35 | 36 |
|
36 | | -const dependencyCompletion = async (complete: any) => { |
| 37 | +const dependencyCompletion = async (complete: Complete) => { |
37 | 38 | const deps = getPackageJsonDependencies(); |
38 | 39 | deps.forEach((dep) => complete(dep, '')); |
39 | 40 | }; |
@@ -72,7 +73,11 @@ export async function setupPnpmCompletions( |
72 | 73 | } |
73 | 74 | } |
74 | 75 | } catch (error) { |
75 | | - console.error('Failed to setup pnpm completions:', error.message); |
| 76 | + if (error instanceof Error) { |
| 77 | + console.error('Failed to setup pnpm completions:', error.message); |
| 78 | + } else { |
| 79 | + console.error('Failed to setup pnpm completions:', error); |
| 80 | + } |
76 | 81 | } |
77 | 82 | } |
78 | 83 |
|
@@ -143,7 +148,11 @@ async function getPnpmCommandsFromMainHelp(): Promise<Record<string, string>> { |
143 | 148 |
|
144 | 149 | return commands; |
145 | 150 | } catch (error) { |
146 | | - console.error('Error parsing pnpm help:', error.message); |
| 151 | + if (error instanceof Error) { |
| 152 | + console.error('Failed to setup pnpm completions:', error.message); |
| 153 | + } else { |
| 154 | + console.error('Failed to setup pnpm completions:', error); |
| 155 | + } |
147 | 156 | return {}; |
148 | 157 | } |
149 | 158 | } |
|
0 commit comments