1- const path = require ( 'path' ) ;
2- const mkdirp = require ( 'mkdirp' ) ;
1+ const path = require ( 'path' )
2+ const mkdirp = require ( 'mkdirp' )
33
4- const output = require ( '../../output' ) ;
5- const { fileExists } = require ( '../../utils' ) ;
6- const {
7- getConfig, getTestRoot, updateConfig, safeFileWrite, findConfigFile,
8- } = require ( '../utils' ) ;
4+ const output = require ( '../../output' )
5+ const { fileExists } = require ( '../../utils' )
6+ const { getConfigSync, getTestRoot, updateConfig, safeFileWrite, findConfigFile } = require ( '../utils' )
97
108const featureFile = `Feature: Business rules
119 In order to achieve my goals
@@ -14,68 +12,64 @@ const featureFile = `Feature: Business rules
1412
1513 Scenario: do something
1614 Given I have a defined step
17- ` ;
15+ `
1816
1917const stepsFile = `const { I } = inject();
2018// Add in your custom step files
2119
2220Given('I have a defined step', () => {
2321 // TODO: replace with your own step
2422});
25- ` ;
23+ `
2624
2725module . exports = function ( genPath ) {
28- const testsPath = getTestRoot ( genPath ) ;
29- const configFile = findConfigFile ( testsPath ) ;
26+ const testsPath = getTestRoot ( genPath )
27+ const configFile = findConfigFile ( testsPath )
3028
3129 if ( ! configFile ) {
32- output . error (
33- "Can't initialize Gherkin. This command must be run in an already initialized project." ,
34- ) ;
35- process . exit ( 1 ) ;
30+ output . error ( "Can't initialize Gherkin. This command must be run in an already initialized project." )
31+ process . exit ( 1 )
3632 }
3733
38- const config = getConfig ( testsPath ) ;
39- const extension = path . extname ( configFile ) . substring ( 1 ) ;
34+ const config = getConfigSync ( testsPath )
35+ const extension = path . extname ( configFile ) . substring ( 1 )
4036
41- output . print ( 'Initializing Gherkin (Cucumber BDD) for CodeceptJS' ) ;
42- output . print ( '--------------------------' ) ;
37+ output . print ( 'Initializing Gherkin (Cucumber BDD) for CodeceptJS' )
38+ output . print ( '--------------------------' )
4339
4440 if ( config . gherkin && config . gherkin . steps ) {
45- output . error ( 'Gherkin is already initialized in this project. See `gherkin` section in the config' ) ;
46- process . exit ( 1 ) ;
41+ output . error ( 'Gherkin is already initialized in this project. See `gherkin` section in the config' )
42+ process . exit ( 1 )
4743 }
4844
49- let dir ;
50- dir = path . join ( testsPath , 'features' ) ;
45+ let dir
46+ dir = path . join ( testsPath , 'features' )
5147 if ( ! fileExists ( dir ) ) {
52- mkdirp . sync ( dir ) ;
53- output . success ( `Created ${ dir } , place your *.feature files in it` ) ;
48+ mkdirp . sync ( dir )
49+ output . success ( `Created ${ dir } , place your *.feature files in it` )
5450 }
5551
5652 if ( safeFileWrite ( path . join ( dir , 'basic.feature' ) , featureFile ) ) {
57- output . success ( 'Created sample feature file: features/basic.feature' ) ;
53+ output . success ( 'Created sample feature file: features/basic.feature' )
5854 }
5955
60- dir = path . join ( testsPath , 'step_definitions' ) ;
56+ dir = path . join ( testsPath , 'step_definitions' )
6157 if ( ! fileExists ( dir ) ) {
62- mkdirp . sync ( dir ) ;
63- output . success ( `Created ${ dir } , place step definitions into it` ) ;
58+ mkdirp . sync ( dir )
59+ output . success ( `Created ${ dir } , place step definitions into it` )
6460 }
6561
6662 if ( safeFileWrite ( path . join ( dir , `steps.${ extension } ` ) , stepsFile ) ) {
67- output . success (
68- `Created sample steps file: step_definitions/steps.${ extension } ` ,
69- ) ;
63+ output . success ( `Created sample steps file: step_definitions/steps.${ extension } ` )
7064 }
7165
7266 config . gherkin = {
7367 features : './features/*.feature' ,
7468 steps : [ `./step_definitions/steps.${ extension } ` ] ,
75- } ;
69+ }
7670
77- updateConfig ( testsPath , config , extension ) ;
71+ updateConfig ( testsPath , config , extension )
7872
79- output . success ( 'Gherkin setup is done.' ) ;
80- output . success ( 'Start writing feature files and implement corresponding steps.' ) ;
81- } ;
73+ output . success ( 'Gherkin setup is done.' )
74+ output . success ( 'Start writing feature files and implement corresponding steps.' )
75+ }
0 commit comments