Total Complexity | 2 |
Complexity/F | 2 |
Lines of Code | 23 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import * as vscode from 'vscode'; |
||
2 | |||
3 | interface CommandMessages { |
||
4 | SUCCESS_MESSAGE: string; |
||
5 | ERROR_MESSAGE: string; |
||
6 | } |
||
7 | |||
8 | type CommandHandler = (...args: any[]) => void; |
||
9 | |||
10 | export function commandDecorator(command: CommandHandler, messages: CommandMessages):CommandHandler { |
||
11 | return (...args: any[]) => { |
||
12 | const { SUCCESS_MESSAGE, ERROR_MESSAGE } = messages; |
||
13 | |||
14 | try { |
||
15 | command(...args); |
||
16 | vscode.window.showInformationMessage(SUCCESS_MESSAGE); |
||
17 | } catch (error) { |
||
18 | console.error(error); |
||
19 | vscode.window.showErrorMessage(ERROR_MESSAGE); |
||
20 | } |
||
21 | }; |
||
22 | } |
||
23 |