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