1
1
#!/usr/bin/env node
2
- import program from 'commander' ;
3
- import Codecept from '../lib/codecept' ;
2
+ import { program } from 'commander' ;
3
+ import Codecept from '../lib/codecept.js ' ;
4
4
import { print , error } from '../lib/output.js' ;
5
5
import { printError } from '../lib/command/utils.js' ;
6
+ import * as init from '../lib/command/init.js' ;
7
+ import * as configMigrate from '../lib/command/configMigrate.js' ;
8
+ import * as interactive from '../lib/command/interactive.js' ;
9
+ import * as definitions from '../lib/command/definitions.js' ;
10
+ import * as list from '../lib/command/list.js' ;
11
+ import * as gherkinInit from '../lib/command/gherkin/init.js' ;
12
+ import * as gherkinSteps from '../lib/command/gherkin/steps.js' ;
13
+ import * as gherkinSnippets from '../lib/command/gherkin/snippets.js' ;
14
+ import * as generate from '../lib/command/generate.js' ;
15
+ import * as run from '../lib/command/run.js' ;
16
+ import * as runWorkers from '../lib/command/run-workers.js' ;
17
+ import * as runMultiple from '../lib/command/run-multiple.js' ;
18
+ import * as rerun from '../lib/command/run-rerun.js' ;
19
+ import * as dryRun from '../lib/command/dryRun.js' ;
20
+ import * as info from '../lib/command/info.js' ;
6
21
7
22
const errorHandler = ( fn ) => async ( ...args ) => {
8
23
try {
@@ -26,42 +41,42 @@ program.version(Codecept.version());
26
41
27
42
program . command ( 'init [path]' )
28
43
. description ( 'Creates dummy config in current dir or [path]' )
29
- . action ( errorHandler ( require ( '../lib/command/ init' ) ) ) ;
44
+ . action ( errorHandler ( init ) ) ;
30
45
31
46
program . command ( 'migrate [path]' )
32
47
. description ( 'Migrate json config to js config in current dir or [path]' )
33
- . action ( errorHandler ( require ( '../lib/command/ configMigrate' ) ) ) ;
48
+ . action ( errorHandler ( configMigrate ) ) ;
34
49
35
50
program . command ( 'shell [path]' )
36
51
. alias ( 'sh' )
37
52
. description ( 'Interactive shell' )
38
53
. option ( '--verbose' , 'output internal logging information' )
39
54
. option ( '--profile [value]' , 'configuration profile to be used' )
40
55
. option ( '-c, --config [file]' , 'configuration file to be used' )
41
- . action ( errorHandler ( require ( '../lib/command/ interactive' ) ) ) ;
56
+ . action ( errorHandler ( interactive ) ) ;
42
57
43
58
program . command ( 'list [path]' )
44
59
. alias ( 'l' )
45
60
. description ( 'List all actions for I.' )
46
- . action ( errorHandler ( require ( '../lib/command/ list' ) ) ) ;
61
+ . action ( errorHandler ( list ) ) ;
47
62
48
63
program . command ( 'def [path]' )
49
64
. description ( 'Generates TypeScript definitions for all I actions.' )
50
65
. option ( '-c, --config [file]' , 'configuration file to be used' )
51
66
. option ( '-o, --output [folder]' , 'target folder to paste definitions' )
52
- . action ( errorHandler ( require ( '../lib/command/ definitions' ) ) ) ;
67
+ . action ( errorHandler ( definitions ) ) ;
53
68
54
69
program . command ( 'gherkin:init [path]' )
55
70
. alias ( 'bdd:init' )
56
71
. description ( 'Prepare CodeceptJS to run feature files.' )
57
72
. option ( '-c, --config [file]' , 'configuration file to be used' )
58
- . action ( errorHandler ( require ( '../lib/command/gherkin/init' ) ) ) ;
73
+ . action ( errorHandler ( gherkinInit ) ) ;
59
74
60
75
program . command ( 'gherkin:steps [path]' )
61
76
. alias ( 'bdd:steps' )
62
77
. description ( 'Prints all defined gherkin steps.' )
63
78
. option ( '-c, --config [file]' , 'configuration file to be used' )
64
- . action ( errorHandler ( require ( '../lib/command/gherkin/steps' ) ) ) ;
79
+ . action ( errorHandler ( gherkinSteps ) ) ;
65
80
66
81
program . command ( 'gherkin:snippets [path]' )
67
82
. alias ( 'bdd:snippets' )
@@ -70,28 +85,28 @@ program.command('gherkin:snippets [path]')
70
85
. option ( '-c, --config [file]' , 'configuration file to be used' )
71
86
. option ( '--feature [file]' , 'feature files(s) to scan' )
72
87
. option ( '--path [file]' , 'file in which to place the new snippets' )
73
- . action ( errorHandler ( require ( '../lib/command/gherkin/snippets' ) ) ) ;
88
+ . action ( errorHandler ( gherkinSnippets ) ) ;
74
89
75
90
program . command ( 'generate:test [path]' )
76
91
. alias ( 'gt' )
77
92
. description ( 'Generates an empty test' )
78
- . action ( errorHandler ( require ( '../lib/command/ generate' ) . test ) ) ;
93
+ . action ( errorHandler ( generate . test ) ) ;
79
94
80
95
program . command ( 'generate:pageobject [path]' )
81
96
. alias ( 'gpo' )
82
97
. description ( 'Generates an empty page object' )
83
- . action ( errorHandler ( require ( '../lib/command/ generate' ) . pageObject ) ) ;
98
+ . action ( errorHandler ( generate . pageObject ) ) ;
84
99
85
100
program . command ( 'generate:object [path]' )
86
101
. alias ( 'go' )
87
102
. option ( '--type, -t [kind]' , 'type of object to be created' )
88
103
. description ( 'Generates an empty support object (page/step/fragment)' )
89
- . action ( errorHandler ( require ( '../lib/command/ generate' ) . pageObject ) ) ;
104
+ . action ( errorHandler ( generate . pageObject ) ) ;
90
105
91
106
program . command ( 'generate:helper [path]' )
92
107
. alias ( 'gh' )
93
108
. description ( 'Generates a new helper' )
94
- . action ( errorHandler ( require ( '../lib/command/ generate' ) . helper ) ) ;
109
+ . action ( errorHandler ( generate . helper ) ) ;
95
110
96
111
program . command ( 'run [test]' )
97
112
. description ( 'Executes tests' )
@@ -128,7 +143,7 @@ program.command('run [test]')
128
143
. option ( '--recursive' , 'include sub directories' )
129
144
. option ( '--trace' , 'trace function calls' )
130
145
. option ( '--child <string>' , 'option for child processes' )
131
- . action ( errorHandler ( require ( '../lib/command/ run' ) ) ) ;
146
+ . action ( errorHandler ( run ) ) ;
132
147
133
148
program . command ( 'run-workers <workers> [selectedRuns...]' )
134
149
. description ( 'Executes tests in workers' )
@@ -145,7 +160,7 @@ program.command('run-workers <workers> [selectedRuns...]')
145
160
. option ( '-p, --plugins <k=v,k2=v2,...>' , 'enable plugins, comma-separated' )
146
161
. option ( '-O, --reporter-options <k=v,k2=v2,...>' , 'reporter-specific options' )
147
162
. option ( '-R, --reporter <name>' , 'specify the reporter to use' )
148
- . action ( errorHandler ( require ( '../lib/command/run-workers' ) ) ) ;
163
+ . action ( errorHandler ( runWorkers ) ) ;
149
164
150
165
program . command ( 'run-multiple [suites...]' )
151
166
. description ( 'Executes tests multiple' )
@@ -169,12 +184,12 @@ program.command('run-multiple [suites...]')
169
184
// mocha options
170
185
. option ( '--colors' , 'force enabling of colors' )
171
186
172
- . action ( errorHandler ( require ( '../lib/command/run-multiple' ) ) ) ;
187
+ . action ( errorHandler ( runMultiple ) ) ;
173
188
174
189
program . command ( 'info [path]' )
175
190
. description ( 'Print debugging information concerning the local environment' )
176
191
. option ( '-c, --config' , 'your config file path' )
177
- . action ( errorHandler ( require ( '../lib/command/ info' ) ) ) ;
192
+ . action ( errorHandler ( info ) ) ;
178
193
179
194
program . command ( 'dry-run [test]' )
180
195
. description ( 'Prints step-by-step scenario for a test without actually running it' )
@@ -190,7 +205,7 @@ program.command('dry-run [test]')
190
205
. option ( '--steps' , 'show step-by-step execution' )
191
206
. option ( '--verbose' , 'output internal logging information' )
192
207
. option ( '--debug' , 'output additional information' )
193
- . action ( errorHandler ( require ( '../lib/command/ dryRun' ) ) ) ;
208
+ . action ( errorHandler ( dryRun ) ) ;
194
209
195
210
program . command ( 'run-rerun [test]' )
196
211
. description ( 'Executes tests in more than one test suite run' )
@@ -227,7 +242,7 @@ program.command('run-rerun [test]')
227
242
. option ( '--trace' , 'trace function calls' )
228
243
. option ( '--child <string>' , 'option for child processes' )
229
244
230
- . action ( require ( '../lib/command/run- rerun' ) ) ;
245
+ . action ( rerun ) ;
231
246
232
247
program . on ( 'command:*' , ( cmd ) => {
233
248
console . log ( `\nUnknown command ${ cmd } \n` ) ;
0 commit comments