https://github.com/cucumber/gherkin-streams
Stream utilities to read Gherkin parser output.
https://github.com/cucumber/gherkin-streams
Last synced: 8 months ago
JSON representation
Stream utilities to read Gherkin parser output.
- Host: GitHub
- URL: https://github.com/cucumber/gherkin-streams
- Owner: cucumber
- Created: 2022-03-01T16:03:26.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-10T18:49:44.000Z (about 2 years ago)
- Last Synced: 2024-04-14T13:08:33.622Z (about 2 years ago)
- Language: TypeScript
- Homepage: https://cucumber.io/
- Size: 659 KB
- Stars: 2
- Watchers: 74
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Gherkin Streams
This module contains utilities to use the Gherkin library with streams.
## Installation
`gherkin-streams` has 3 peer dependencies: `@cucumber/gherkin`, `@cucumber/messages`
and `@cucumber/message-streams`.
You need to have `@cucumber/gherkin` and`@cucumber/message-streams` in your dependencies,
`@cucumber/messages` is actually installed automatically with `@cucumber/gherkin`.
npm install @cucumber/gherkin-streams @cucumber/gherkin @cucumber/message-streams
## Usage
```javascript
const { GherkinStreams } = require('@cucumber/gherkin-streams')
const options = {
includeSource: true,
includeGherkinDocument: true,
includePickles: true,
}
const stream = GherkinStreams.fromPaths(['features/hello.feature'])
// Pipe the stream to another stream that can read messages.
stream.pipe(...)
```
### Shortening URIs with `relativeTo`
You can include `relativeTo` option to avoid emitting longer or absolute URIs, instead making them only relative to the current working directory (or whatever makes sense for your use case):
```javascript
const { GherkinStreams } = require('@cucumber/gherkin-streams')
// imagine `discoverPaths()` is a function that returns absolute paths
const paths = discoverPaths();
const options = {
includeSource: true,
includeGherkinDocument: true,
includePickles: true,
relativeTo: process.cwd()
}
const stream = GherkinStreams.fromPaths(paths)
// Pipe the stream to another stream that can read messages.
stream.pipe(...)
```