Skip to content

Commit ba71328

Browse files
committed
Merge branch 'fix-spaces-dev-path-again' of github.com:cucumber/cucumber-js into fix-spaces-dev-path-again
2 parents 65ba09d + c9974e7 commit ba71328

File tree

9 files changed

+133
-10
lines changed

9 files changed

+133
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,18 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
1010
## [Unreleased]
1111
### Fixed
1212
- Handles spaces in paths for developers working on cucumbers's own code ([#1845](https://github.com/cucumber/cucumber-js/issues/1845))
13+
- Ensure package.json can be imported by consuming projects
14+
([PR#1870](https://github.com/cucumber/cucumber-js/pull/1870)
15+
[Issue#1869](https://github.com/cucumber/cucumber-js/issues/1869))
1316
- Allows for parentheses in paths for developers working on cucumber's own code ([[#1735](https://github.com/cucumber/cucumber-js/issues/1735)])
1417
- Smoother onboarding for Windows developers ([#1863](https://github.com/cucumber/cucumber-js/pull/1863))
1518

19+
### Added
20+
- Export cucumber version number. It is now possible to retrieve the current version
21+
of cucumber using `import { version } from '@cucumber/cucumber'`.
22+
([PR#1866](https://github.com/cucumber/cucumber-js/pull/1866)
23+
[Issue#1853](https://github.com/cucumber/cucumber-js/issues/1853))
24+
1625
## [8.0.0-rc.1] - 2021-10-19
1726
### Added
1827
- Add `wrapPromiseWithTimeout` to public API ([#1566](https://github.com/cucumber/cucumber-js/pull/1566))

features/direct_imports.feature

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,26 @@ Feature: Core feature elements execution using direct imports
6060
Given(/^a step passes$/, function() {});
6161
"""
6262
When I run cucumber-js
63-
Then it passes
63+
Then it passes
64+
65+
Scenario: we can import the version number from package.json and from the library
66+
Given a file named "features/a.feature" with:
67+
"""
68+
Feature: some feature
69+
Scenario: some scenario
70+
Given a step checks the version number
71+
"""
72+
And a file named "features/step_definitions/cucumber_steps.js" with:
73+
"""
74+
const {Given} = require('@cucumber/cucumber')
75+
const package_version = require('@cucumber/cucumber/package.json').version
76+
const library_version = require('@cucumber/cucumber').version
77+
78+
Given(/^a step checks the version number$/, function() {
79+
if (package_version !== library_version) {
80+
throw new Error(`package version: ${package_version} !== library version: ${library_version}`)
81+
}
82+
});
83+
"""
84+
When I run cucumber-js
85+
Then it passes

features/step_definitions/cli_steps.ts

Lines changed: 1 addition & 2 deletions
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

Lines changed: 92 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@
175175
},
176176
"./lib/*": {
177177
"require": "./lib/*.js"
178-
}
178+
},
179+
"./package.json": "./package.json"
179180
},
180181
"types": "./lib/index.d.ts",
181182
"engines": {
@@ -251,6 +252,7 @@
251252
"eslint-plugin-standard": "4.1.0",
252253
"express": "4.17.1",
253254
"fs-extra": "10.0.0",
255+
"genversion": "^3.0.2",
254256
"mocha": "9.1.3",
255257
"mustache": "4.2.0",
256258
"nyc": "15.1.0",
@@ -267,7 +269,7 @@
267269
"typescript": "4.5.2"
268270
},
269271
"scripts": {
270-
"build-local": "tsc --build tsconfig.node.json && shx cp src/importer.js lib/ && shx cp src/wrapper.mjs lib/",
272+
"build-local": "genversion --es6 src/version.ts && tsc --build tsconfig.node.json && shx cp src/importer.js lib/ && shx cp src/wrapper.mjs lib/",
271273
"cck-test": "mocha 'compatibility/**/*_spec.ts'",
272274
"feature-test": "node ./bin/cucumber-js",
273275
"html-formatter": "node ./bin/cucumber-js --profile htmlFormatter",

src/cli/argv_parser.ts

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 0 deletions
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)