MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / getDefinitionsFileContent

Function getDefinitionsFileContent

lib/command/definitions.js:24–54  ·  view source on GitHub ↗
({ hasCustomHelper, hasCustomStepsFile, helperNames, supportObject, importPaths, translations })

Source from the content-addressed store, hash-verified

22 * @returns {string}
23 */
24const getDefinitionsFileContent = ({ hasCustomHelper, hasCustomStepsFile, helperNames, supportObject, importPaths, translations }) => {
25 const getHelperListFragment = ({ hasCustomHelper, hasCustomStepsFile }) => {
26 if (hasCustomHelper && hasCustomStepsFile) {
27 return `${['ReturnType<steps_file>', 'WithTranslation<Methods>'].join(', ')}`
28 }
29
30 if (hasCustomStepsFile) {
31 return 'ReturnType<steps_file>'
32 }
33
34 return 'WithTranslation<Methods>'
35 }
36
37 const helpersListFragment = getHelperListFragment({
38 hasCustomHelper,
39 hasCustomStepsFile,
40 })
41
42 const importPathsFragment = importPaths.join('\n')
43 const supportObjectsTypeFragment = convertMapToType(supportObject)
44 const methodsTypeFragment = helperNames.length > 0 ? `interface Methods extends ${helperNames.join(', ')} {}` : 'interface Methods {}'
45 const translatedActionsFragment = JSON.stringify(translations.vocabulary.actions, null, 2)
46
47 return generateDefinitionsContent({
48 helpersListFragment,
49 importPathsFragment,
50 supportObjectsTypeFragment,
51 methodsTypeFragment,
52 translatedActionsFragment,
53 })
54}
55
56/**
57 * Generate content for definitions file from fragments

Callers 1

definitions.jsFile · 0.85

Calls 3

getHelperListFragmentFunction · 0.85
convertMapToTypeFunction · 0.85

Tested by

no test coverage detected