Skip to content

Commit 42d95b6

Browse files
Export version number of cucumber-js (#1866)
* Export version number of cucumber-js * Update CHANGELOG.md
1 parent efff3a3 commit 42d95b6

File tree

8 files changed

+105
-8
lines changed

8 files changed

+105
-8
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ usage.txt
1313
yarn-error.log
1414
.vscode
1515
.DS_Store
16+
src/version.ts

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
1212
- Allows for parentheses in paths for developers working on cucumber's own code ([[#1735](https://github.com/cucumber/cucumber-js/issues/1735)])
1313
- Smoother onboarding for Windows developers ([#1863](https://github.com/cucumber/cucumber-js/pull/1863))
1414

15+
### Added
16+
- Export cucumber version number. It is now possible to retrieve the current version
17+
of cucumber using `import { version } from '@cucumber/cucumber'`.
18+
([PR#1866](https://github.com/cucumber/cucumber-js/pull/1866)
19+
[Issue#1853](https://github.com/cucumber/cucumber-js/issues/1853))
20+
1521
## [8.0.0-rc.1] - 2021-10-19
1622
### Added
1723
- Add `wrapPromiseWithTimeout` to public API ([#1566](https://github.com/cucumber/cucumber-js/pull/1566))

features/step_definitions/cli_steps.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import {
99
valueOrDefault,
1010
} from '../../src/value_checker'
1111
import { World } from '../support/world'
12-
13-
const { version } = require('../../package.json') // eslint-disable-line @typescript-eslint/no-var-requires
12+
import { version } from '../../src/version'
1413

1514
When('my env includes {string}', function (this: World, envString: string) {
1615
this.sharedEnv = this.parseEnvString(envString)

package-lock.json

+92
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@
251251
"eslint-plugin-standard": "4.1.0",
252252
"express": "4.17.1",
253253
"fs-extra": "10.0.0",
254+
"genversion": "^3.0.2",
254255
"mocha": "9.1.3",
255256
"mustache": "4.2.0",
256257
"nyc": "15.1.0",
@@ -267,7 +268,7 @@
267268
"typescript": "4.5.2"
268269
},
269270
"scripts": {
270-
"build-local": "tsc --build tsconfig.node.json && shx cp src/importer.js lib/ && shx cp src/wrapper.mjs lib/",
271+
"build-local": "genversion --es6 src/version.ts && tsc --build tsconfig.node.json && shx cp src/importer.js lib/ && shx cp src/wrapper.mjs lib/",
271272
"cck-test": "mocha 'compatibility/**/*_spec.ts'",
272273
"feature-test": "node ./bin/cucumber-js",
273274
"html-formatter": "node ./bin/cucumber-js --profile htmlFormatter",

src/cli/argv_parser.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { dialects } from '@cucumber/gherkin'
44
import { SnippetInterface } from '../formatter/step_definition_snippet_builder/snippet_syntax'
55
import { getKeywords, getLanguages } from './i18n'
66
import Formatters from '../formatter/helpers/formatters'
7+
import { version } from '../version'
78
import { PickleOrder } from './helpers'
89

9-
// Using require instead of import so compiled typescript will have the desired folder structure
10-
const { version } = require('../../package.json') // eslint-disable-line @typescript-eslint/no-var-requires
11-
1210
export interface IParsedArgvFormatRerunOptions {
1311
separator?: string
1412
}

src/cli/helpers.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ISupportCodeLibrary } from '../support_code_library_builder/types'
1414
import TestCaseHookDefinition from '../models/test_case_hook_definition'
1515
import TestRunHookDefinition from '../models/test_run_hook_definition'
1616
import { builtinParameterTypes } from '../support_code_library_builder'
17+
import { version } from '../version'
1718

1819
export interface IGetExpandedArgvRequest {
1920
argv: string[]
@@ -117,8 +118,6 @@ export async function emitMetaMessage(
117118
eventBroadcaster: EventEmitter,
118119
env: NodeJS.ProcessEnv
119120
): Promise<void> {
120-
// eslint-disable-next-line @typescript-eslint/no-var-requires
121-
const { version } = require('../../package.json')
122121
eventBroadcaster.emit('envelope', {
123122
meta: createMeta('cucumber-js', version, env),
124123
})

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export {
1313
} from './runtime'
1414
export { default as supportCodeLibraryBuilder } from './support_code_library_builder'
1515
export { default as DataTable } from './models/data_table'
16+
export { version } from './version'
1617

1718
// Formatters
1819
export { default as Formatter, IFormatterOptions } from './formatter'

0 commit comments

Comments
 (0)