Skip to content

Commit 6589290

Browse files
Add package.json to node module exports (#1870)
* Add package.json to node module exports * Update changelog * Add a scenario to validate we can export package.json and version numbers * Use template literal rather than string concatenation in direct_imports.feature * Change entry in the changelog
1 parent 42d95b6 commit 6589290

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
99

1010
## [Unreleased]
1111
### Fixed
12+
- Ensure package.json can be imported by consuming projects
13+
([PR#1870](https://github.com/cucumber/cucumber-js/pull/1870)
14+
[Issue#1869](https://github.com/cucumber/cucumber-js/issues/1869))
1215
- Allows for parentheses in paths for developers working on cucumber's own code ([[#1735](https://github.com/cucumber/cucumber-js/issues/1735)])
1316
- Smoother onboarding for Windows developers ([#1863](https://github.com/cucumber/cucumber-js/pull/1863))
1417

features/direct_imports.feature

+23-1
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

package.json

+2-1
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": {

0 commit comments

Comments
 (0)