Skip to content

Commit

Permalink
Add package.json to node module exports (#1870)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
aurelien-reeves authored Dec 13, 2021
1 parent 42d95b6 commit 6589290
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO

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

Expand Down
24 changes: 23 additions & 1 deletion features/direct_imports.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,26 @@ Feature: Core feature elements execution using direct imports
Given(/^a step passes$/, function() {});
"""
When I run cucumber-js
Then it passes
Then it passes

Scenario: we can import the version number from package.json and from the library
Given a file named "features/a.feature" with:
"""
Feature: some feature
Scenario: some scenario
Given a step checks the version number
"""
And a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {Given} = require('@cucumber/cucumber')
const package_version = require('@cucumber/cucumber/package.json').version
const library_version = require('@cucumber/cucumber').version
Given(/^a step checks the version number$/, function() {
if (package_version !== library_version) {
throw new Error(`package version: ${package_version} !== library version: ${library_version}`)
}
});
"""
When I run cucumber-js
Then it passes
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@
},
"./lib/*": {
"require": "./lib/*.js"
}
},
"./package.json": "./package.json"
},
"types": "./lib/index.d.ts",
"engines": {
Expand Down

0 comments on commit 6589290

Please sign in to comment.