Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 38 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import Drush from '../tools/drush' |
||
2 | import Expose from '../tools/expose' |
||
3 | import Magerun from '../tools/magerun' |
||
4 | import Magerun2 from '../tools/magerun2' |
||
5 | import Tool from '../tools/tool' |
||
6 | import WpCli from '../tools/wpCli' |
||
7 | |||
8 | const getToolByName = (toolName: string): Tool => { |
||
9 | let tool: Tool |
||
10 | |||
11 | switch (toolName) { |
||
12 | // TODO: Improve the way we handle these checks. This is very NOT memory efficient |
||
13 | // as we are constantly initiating new objects. |
||
14 | case (new WpCli).alias || (new WpCli).name: |
||
15 | tool = new WpCli() |
||
16 | break |
||
17 | case (new Magerun).alias || (new Magerun).name: |
||
18 | tool = new Magerun() |
||
19 | break |
||
20 | case (new Magerun2).alias || (new Magerun2).name: |
||
21 | tool = new Magerun2() |
||
22 | break |
||
23 | case (new Drush).alias || (new Drush).name: |
||
24 | tool = new Drush() |
||
25 | break |
||
26 | case (new Expose).alias || (new Expose).name: |
||
27 | tool = new Expose() |
||
28 | break |
||
29 | default: |
||
30 | throw Error('Invalid tool: ' + toolName) |
||
31 | } |
||
32 | |||
33 | return tool |
||
34 | } |
||
35 | |||
36 | export { |
||
37 | getToolByName |
||
38 | } |