Skip to content

Commit 94e1da2

Browse files
committed
Revert formatting changes
1 parent 7c104ba commit 94e1da2

File tree

4 files changed

+17
-32
lines changed

4 files changed

+17
-32
lines changed

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ Gherkin Utils is [available on Maven Central](https://central.sonatype.com/artif
5454

5555
## Command line
5656

57+
Running Gherkin Utils from the command line provides formatting and conversion features.
58+
5759
```bash
58-
-> npx @cucumber/gherkin-utils format features
60+
> npx @cucumber/gherkin-utils format features
5961
❌ 7 files failed to format
6062
🥒 14 files left unchanged
6163
🥒 25 files reformatted
@@ -102,9 +104,9 @@ This module can also be used as a library. It provides two main utilities, `pret
102104
This function takes a GherkinDocument as input and returns a pretty-printed representation in Gherkin or Markdown.
103105

104106
```javascript
105-
import { AstBuilder, GherkinClassicTokenMatcher,Parser } from "@cucumber/gherkin";
106-
import { pretty } from "@cucumber/gherkin-utils"
107-
import { IdGenerator } from "@cucumber/messages"
107+
import { AstBuilder, GherkinClassicTokenMatcher, Parser } from '@cucumber/gherkin'
108+
import { pretty } from '@cucumber/gherkin-utils'
109+
import { IdGenerator } from '@cucumber/messages'
108110

109111
const uuidFn = IdGenerator.uuid()
110112

@@ -126,7 +128,7 @@ Feature:
126128
Given step text
127129
128130
*/
129-
const formattedGherkinMarkdownFeature = pretty(gherkinDocument, "markdown")
131+
const formattedGherkinMarkdownFeature = pretty(gherkinDocument, 'markdown')
130132
/*
131133
# Feature:
132134
@@ -156,22 +158,19 @@ By default, all elements are accepted, which means that if you want to do filter
156158
Here's an example:
157159

158160
```typescript
159-
import { GherkinDocumentWalker, rejectAllFilters } from "@cucumber/gherkin-utils"
161+
import { GherkinDocumentWalker, rejectAllFilters } from '@cucumber/gherkin-utils';
160162

161163
// Only keeps scenarios which name include 'magic'
162164
const filter = new GherkinDocumentWalker({
163165
...rejectAllFilters,
164-
...{ acceptScenario: (scenario) => scenario.name.includes("magic") },
166+
...{ acceptScenario: (scenario) => scenario.name.includes('magic') },
165167
})
166168

167169
// Makes a list with all the scenario names
168-
const allScenarioNames: string[] = [];
169-
const scenarioNameFinder = new GherkinDocumentWalker(
170-
{},
171-
{
172-
handleScenario: (scenario) => allScenarioNames.push(scenario.name),
173-
}
174-
)
170+
const allScenarioNames: string[] = []
171+
const scenarioNameFinder = new GherkinDocumentWalker({}, {
172+
handleScenario: (scenario) => allScenarioNames.push(scenario.name),
173+
})
175174
```
176175

177176
## Feedback

javascript/features/file.feature

Lines changed: 0 additions & 4 deletions
This file was deleted.

javascript/features/fqile.feature

Lines changed: 0 additions & 4 deletions
This file was deleted.

javascript/src/commands/formatCommand.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
AstBuilder,
3-
GherkinClassicTokenMatcher,
4-
GherkinInMarkdownTokenMatcher,
5-
Parser,
6-
} from '@cucumber/gherkin'
1+
import { AstBuilder, GherkinClassicTokenMatcher, GherkinInMarkdownTokenMatcher, Parser, } from '@cucumber/gherkin'
72
import * as messages from '@cucumber/messages'
83
import * as diff from 'diff'
94
import fs, { unlink as unlinkCb } from 'fs'
@@ -70,7 +65,7 @@ export async function formatCommand(
7065
writableSyntax: syntaxFromPath(toFile, options.toSyntax),
7166
readable: () => fs.createReadStream(file),
7267
writable: () => fs.createWriteStream(toFile),
73-
afterWrite: file !== toFile ? () => unlink(file) : () => Promise.resolve(),
68+
afterWrite: file !== toFile ? () => unlink(file) : () => Promise.resolve()
7469
}
7570
})
7671
if (stdin && stdout) {
@@ -79,7 +74,7 @@ export async function formatCommand(
7974
writableSyntax: options.toSyntax || 'gherkin',
8075
readable: () => stdin,
8176
writable: () => stdout,
82-
afterWrite: () => Promise.resolve(),
77+
afterWrite: () => Promise.resolve()
8378
})
8479
}
8580

@@ -192,8 +187,7 @@ function syntaxFromPath(file: string, explicitSyntax?: Syntax): Syntax {
192187
if (path.extname(file) === '.feature') syntax = 'gherkin'
193188
if (path.extname(file) === '.md') syntax = 'markdown'
194189
if (!syntax) throw new Error(`Cannot determine syntax from path ${file}`)
195-
if (explicitSyntax && explicitSyntax !== syntax)
196-
throw new Error(`Cannot treat ${file} as ${explicitSyntax}`)
190+
if (explicitSyntax && explicitSyntax !== syntax) throw new Error(`Cannot treat ${file} as ${explicitSyntax}`)
197191
return syntax
198192
}
199193

0 commit comments

Comments
 (0)