Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html-formatter: fix when installed locally to node project #1180

Merged
merged 5 commits into from
Sep 12, 2020

Conversation

davidjgoss
Copy link
Contributor

@davidjgoss davidjgoss commented Sep 9, 2020

Summary

Fixes the @cucumber/html-formatter CLI when the package is installed as a project dependency (rather than only working when installed globally).

Details

Installing to a project like npm i @cucumber/html-formatter and then running in an npm script would currently yield an error like:

[Error: ENOENT: no such file or directory, open '/Users/davidgoss/Documents/Projects/html-formatter-test/node_modules/@cucumber/html-formatter/dist/src/../../node_modules/@cucumber/react/dist/src/styles/cucumber-react.css'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/davidgoss/Documents/Projects/html-formatter-test/node_modules/@cucumber/html-formatter/dist/src/../../node_modules/@cucumber/react/dist/src/styles/cucumber-react.css'
}
npm ERR! Test failed.  See above for more details.

This is due to the relative path to the cucumber react CSS file - this breaks when installed as a dependency, because our own dependencies are usually hoisted up to the node_modules of the host project.

This changes to use a reliable function to resolve the path to the @cucumber/react package so it works in global or local context.

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • The change has been ported to Java.
  • The change has been ported to Ruby.
  • The change has been ported to JavaScript.
  • The change has been ported to Go.
  • The change has been ported to .NET.
  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have updated the CHANGELOG accordingly.

@davidjgoss davidjgoss marked this pull request as draft September 9, 2020 22:39
@davidjgoss
Copy link
Contributor Author

Actually realised I'll need to do some changes here for cucumber/cucumber-js#1425, so will pick that up on this branch too.

@aslakhellesoy aslakhellesoy merged commit c075db3 into master Sep 12, 2020
@aslakhellesoy aslakhellesoy deleted the html-formatter-local-install branch September 12, 2020 21:57
@aslakhellesoy
Copy link
Contributor

Awesome - thanks @davidjgoss !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants