gherkin
Advanced tools
Comparing version 8.2.1 to 9.0.0
import AstNode from './AstNode'; | ||
import { messages } from 'cucumber-messages'; | ||
import { messages, IdGenerator } from 'cucumber-messages'; | ||
import { RuleType } from './Parser'; | ||
import Token from './Token'; | ||
import { NewId } from './types'; | ||
export default class AstBuilder { | ||
@@ -10,3 +9,3 @@ private stack; | ||
private readonly newId; | ||
constructor(newId: NewId); | ||
constructor(newId: IdGenerator.NewId); | ||
reset(): void; | ||
@@ -13,0 +12,0 @@ startRule(ruleType: RuleType): void; |
@@ -6,44 +6,39 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var index_1 = __importDefault(require("../index")); | ||
var commander_1 = require("commander"); | ||
var package_json_1 = __importDefault(require("../../package.json")); | ||
var Gherkin_1 = __importDefault(require("../Gherkin")); | ||
var cucumber_messages_1 = require("cucumber-messages"); | ||
var IdGenerator_1 = require("../IdGenerator"); | ||
var args = process.argv.slice(2); | ||
var program = new commander_1.Command(); | ||
program.version(package_json_1.default.version); | ||
program.option('--no-source', 'Do not output Source messages', false); | ||
program.option('--no-ast', 'Do not output GherkinDocument messages', false); | ||
program.option('--no-pickles', 'Do not output Pickle messages', false); | ||
program.option('--predictable-ids', 'Use predictable ids', false); | ||
program.option('-f, --format <format>', 'output format: ndjson|protobuf', 'protobuf'); | ||
program.parse(process.argv); | ||
var paths = program.args; | ||
var options = { | ||
defaultDialect: 'en', | ||
includeSource: true, | ||
includeGherkinDocument: true, | ||
includePickles: true, | ||
newId: IdGenerator_1.uuid(), | ||
includeSource: program.source, | ||
includeGherkinDocument: program.ast, | ||
includePickles: program.pickles, | ||
newId: program.predictableIds | ||
? cucumber_messages_1.IdGenerator.incrementing() | ||
: cucumber_messages_1.IdGenerator.uuid(), | ||
}; | ||
var json = false; | ||
var paths = []; | ||
while (args.length > 0) { | ||
var arg = args.shift(); | ||
switch (arg) { | ||
case '--no-source': | ||
options.includeSource = false; | ||
break; | ||
case '--no-ast': | ||
options.includeGherkinDocument = false; | ||
break; | ||
case '--no-pickles': | ||
options.includePickles = false; | ||
break; | ||
case '--json': | ||
json = true; | ||
break; | ||
case '--predictable-ids': | ||
options.newId = IdGenerator_1.incrementing(); | ||
break; | ||
default: | ||
paths.push(arg); | ||
} | ||
var messageStream = paths.length === 0 | ||
? Gherkin_1.default.fromStream(process.stdin, options) | ||
: Gherkin_1.default.fromPaths(paths, options); | ||
var encodedStream; | ||
switch (program.format) { | ||
case 'ndjson': | ||
encodedStream = new cucumber_messages_1.MessageToNdjsonStream(); | ||
break; | ||
case 'protobuf': | ||
encodedStream = new cucumber_messages_1.MessageToBinaryStream(); | ||
break; | ||
default: | ||
throw new Error("Unsupported format: " + program.format); | ||
} | ||
var messageStream = paths.length === 0 | ||
? index_1.default.fromStream(process.stdin, options) | ||
: index_1.default.fromPaths(paths, options); | ||
var encodedStream = json | ||
? messageStream.pipe(new cucumber_messages_1.ProtobufNdjsonStream()) | ||
: messageStream.pipe(new cucumber_messages_1.ProtobufBinaryStream(cucumber_messages_1.messages.Envelope.encodeDelimited.bind(cucumber_messages_1.messages.Envelope))); | ||
encodedStream.pipe(process.stdout); | ||
messageStream.pipe(encodedStream).pipe(process.stdout); | ||
//# sourceMappingURL=main.js.map |
@@ -117,3 +117,6 @@ "use strict"; | ||
function tokenLocation(token) { | ||
return token.location && token.location.line && token.line && token.line.indent !== undefined | ||
return token.location && | ||
token.location.line && | ||
token.line && | ||
token.line.indent !== undefined | ||
? createLocation_1.default({ | ||
@@ -120,0 +123,0 @@ line: token.location.line, |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
import Dialect from '../Dialect'; | ||
import { IGherkinOptions } from '../types'; | ||
import IGherkinOptions from '../IGherkinOptions'; | ||
export default class GherkinExe { | ||
@@ -8,0 +8,0 @@ private readonly gherkinExe; |
@@ -40,8 +40,8 @@ "use strict"; | ||
var args = options.concat(this.paths); | ||
var gherkin = child_process_1.spawn(this.gherkinExe, args, { stdio: ['pipe', 'pipe', 'inherit'] }); | ||
var protobufMessageStream = new cucumber_messages_1.ProtobufMessageStream(cucumber_messages_1.messages.Envelope.decodeDelimited.bind(cucumber_messages_1.messages.Envelope)); | ||
gherkin.on('error', function (err) { | ||
protobufMessageStream.emit('error', err); | ||
var gherkin = child_process_1.spawn(this.gherkinExe, args, { | ||
stdio: ['pipe', 'pipe', 'inherit'], | ||
}); | ||
gherkin.stdout.pipe(protobufMessageStream); | ||
var toMessageStream = new cucumber_messages_1.BinaryToMessageStream(cucumber_messages_1.messages.Envelope.decodeDelimited.bind(cucumber_messages_1.messages.Envelope)); | ||
gherkin.on('error', function (err) { return toMessageStream.emit('error', err); }); | ||
gherkin.stdout.pipe(toMessageStream); | ||
try { | ||
@@ -61,3 +61,3 @@ for (var _b = __values(this.envelopes), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
gherkin.stdin.end(); | ||
return protobufMessageStream; | ||
return toMessageStream; | ||
}; | ||
@@ -64,0 +64,0 @@ return GherkinExe; |
@@ -1,22 +0,4 @@ | ||
/// <reference types="node" /> | ||
import { IGherkinOptions } from './types'; | ||
import { Readable } from 'stream'; | ||
import ParserMessageStream from './stream/ParserMessageStream'; | ||
import { messages } from 'cucumber-messages'; | ||
import Dialect from './Dialect'; | ||
import { uuid, incrementing } from './IdGenerator'; | ||
export declare function fromStream(stream: Readable, options?: IGherkinOptions): ParserMessageStream; | ||
export declare function fromPaths(paths: string[], options?: IGherkinOptions): Readable; | ||
export declare function fromSources(envelopes: messages.IEnvelope[], options?: IGherkinOptions): Readable; | ||
export declare function dialects(): { | ||
[key: string]: Dialect; | ||
}; | ||
declare const _default: { | ||
fromStream: typeof fromStream; | ||
fromPaths: typeof fromPaths; | ||
fromSources: typeof fromSources; | ||
dialects: typeof dialects; | ||
uuid: typeof uuid; | ||
incrementing: typeof incrementing; | ||
}; | ||
export default _default; | ||
import Gherkin from './Gherkin'; | ||
import IGherkinOptions from './IGherkinOptions'; | ||
export default Gherkin; | ||
export { IGherkinOptions }; |
@@ -6,78 +6,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var types_1 = require("./types"); | ||
var stream_1 = require("stream"); | ||
var ParserMessageStream_1 = __importDefault(require("./stream/ParserMessageStream")); | ||
var fs_1 = __importDefault(require("fs")); | ||
var SourceMessageStream_1 = __importDefault(require("./stream/SourceMessageStream")); | ||
var cucumber_messages_1 = require("cucumber-messages"); | ||
var gherkin_languages_json_1 = __importDefault(require("./gherkin-languages.json")); | ||
var GherkinExe_1 = __importDefault(require("./external/GherkinExe")); | ||
var IdGenerator_1 = require("./IdGenerator"); | ||
function fromStream(stream, options) { | ||
if (options === void 0) { options = {}; } | ||
return stream | ||
.pipe(new cucumber_messages_1.ProtobufMessageStream(cucumber_messages_1.messages.Envelope.decodeDelimited)) | ||
.pipe(new ParserMessageStream_1.default(options)); | ||
} | ||
exports.fromStream = fromStream; | ||
function fromPaths(paths, options) { | ||
if (options === void 0) { options = {}; } | ||
options = types_1.gherkinOptions(options); | ||
if (process.env.GHERKIN_EXECUTABLE) { | ||
return new GherkinExe_1.default(process.env.GHERKIN_EXECUTABLE, paths, [], options).messageStream(); | ||
} | ||
var combinedMessageStream = new stream_1.PassThrough({ | ||
writableObjectMode: true, | ||
readableObjectMode: true, | ||
}); | ||
function pipeSequentially() { | ||
var path = paths.shift(); | ||
if (path !== undefined) { | ||
var parserMessageStream = new ParserMessageStream_1.default(options); | ||
parserMessageStream.on('end', function () { | ||
pipeSequentially(); | ||
}); | ||
var end = paths.length === 0; | ||
fs_1.default.createReadStream(path, { encoding: 'utf-8' }) | ||
.pipe(new SourceMessageStream_1.default(path)) | ||
.pipe(parserMessageStream) | ||
.pipe(combinedMessageStream, { end: end }); | ||
} | ||
} | ||
pipeSequentially(); | ||
return combinedMessageStream; | ||
} | ||
exports.fromPaths = fromPaths; | ||
function fromSources(envelopes, options) { | ||
if (options === void 0) { options = {}; } | ||
options = types_1.gherkinOptions(options); | ||
if (process.env.GHERKIN_EXECUTABLE) { | ||
return new GherkinExe_1.default(process.env.GHERKIN_EXECUTABLE, [], envelopes, options).messageStream(); | ||
} | ||
var combinedMessageStream = new stream_1.PassThrough({ objectMode: true }); | ||
function pipeSequentially() { | ||
var envelope = envelopes.shift(); | ||
if (envelope !== undefined && envelope.source) { | ||
var parserMessageStream = new ParserMessageStream_1.default(options); | ||
parserMessageStream.pipe(combinedMessageStream, { end: envelopes.length === 0 }); | ||
parserMessageStream.on('end', pipeSequentially); | ||
parserMessageStream.end(envelope); | ||
} | ||
} | ||
pipeSequentially(); | ||
return combinedMessageStream; | ||
} | ||
exports.fromSources = fromSources; | ||
function dialects() { | ||
return gherkin_languages_json_1.default; | ||
} | ||
exports.dialects = dialects; | ||
exports.default = { | ||
fromStream: fromStream, | ||
fromPaths: fromPaths, | ||
fromSources: fromSources, | ||
dialects: dialects, | ||
uuid: IdGenerator_1.uuid, | ||
incrementing: IdGenerator_1.incrementing, | ||
}; | ||
var Gherkin_1 = __importDefault(require("./Gherkin")); | ||
exports.default = Gherkin_1.default; | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,3 @@ | ||
import { messages } from 'cucumber-messages'; | ||
import { messages, IdGenerator } from 'cucumber-messages'; | ||
import IGherkinDocument = messages.IGherkinDocument; | ||
import { NewId } from '../types'; | ||
export default function compile(gherkinDocument: IGherkinDocument, uri: string, newId: NewId): messages.IPickle[]; | ||
export default function compile(gherkinDocument: IGherkinDocument, uri: string, newId: IdGenerator.NewId): messages.IPickle[]; |
@@ -45,3 +45,5 @@ "use strict"; | ||
function compileScenario(featureTags, backgroundSteps, scenario, language, pickles, uri, newId) { | ||
var steps = scenario.steps.length === 0 ? [] : backgroundSteps.map(function (step) { return pickleStep(step, [], null, newId); }); | ||
var steps = scenario.steps.length === 0 | ||
? [] | ||
: backgroundSteps.map(function (step) { return pickleStep(step, [], null, newId); }); | ||
var tags = [].concat(featureTags).concat(scenario.tags); | ||
@@ -52,3 +54,3 @@ scenario.steps.forEach(function (step) { return steps.push(pickleStep(step, [], null, newId)); }); | ||
uri: uri, | ||
sourceIds: [scenario.id], | ||
astNodeIds: [scenario.id], | ||
tags: pickleTags(tags), | ||
@@ -67,4 +69,5 @@ name: scenario.name, | ||
examples.tableBody.forEach(function (valuesRow) { | ||
var steps = scenario.steps.length === 0 ? | ||
[] : backgroundSteps.map(function (step) { return pickleStep(step, [], null, newId); }); | ||
var steps = scenario.steps.length === 0 | ||
? [] | ||
: backgroundSteps.map(function (step) { return pickleStep(step, [], null, newId); }); | ||
var tags = [] | ||
@@ -81,3 +84,3 @@ .concat(featureTags) | ||
uri: uri, | ||
sourceIds: [scenario.id, valuesRow.id], | ||
astNodeIds: [scenario.id, valuesRow.id], | ||
name: interpolate(scenario.name, variableCells, valuesRow.cells), | ||
@@ -138,5 +141,5 @@ language: language, | ||
function pickleStep(step, variableCells, valuesRow, newId) { | ||
var sourceIds = [step.id]; | ||
var astNodeIds = [step.id]; | ||
if (valuesRow) { | ||
sourceIds.push(valuesRow.id); | ||
astNodeIds.push(valuesRow.id); | ||
} | ||
@@ -148,3 +151,3 @@ var valueCells = valuesRow ? valuesRow.cells : []; | ||
argument: createPickleArguments(step, variableCells, valueCells), | ||
sourceIds: sourceIds, | ||
astNodeIds: astNodeIds, | ||
}); | ||
@@ -158,5 +161,5 @@ } | ||
name: tag.name, | ||
sourceId: tag.id, | ||
astNodeId: tag.id, | ||
}); | ||
} | ||
//# sourceMappingURL=compile.js.map |
import { messages } from 'cucumber-messages'; | ||
import { IGherkinOptions } from '../types'; | ||
import IGherkinOptions from '../IGherkinOptions'; | ||
export default function generateMessages(data: string, uri: string, options: IGherkinOptions): messages.Envelope[]; |
/// <reference types="node" /> | ||
import { Transform, TransformCallback } from 'stream'; | ||
import { IGherkinOptions } from '../types'; | ||
import { messages } from 'cucumber-messages'; | ||
import IGherkinOptions from '../IGherkinOptions'; | ||
/** | ||
@@ -6,0 +6,0 @@ * Stream that reads Source messages and writes GherkinDocument and Pickle messages. |
{ | ||
"name": "gherkin", | ||
"version": "8.2.1", | ||
"version": "9.0.0", | ||
"description": "Gherkin parser", | ||
@@ -34,18 +34,17 @@ "main": "dist/src/index.js", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^12.12.11", | ||
"@types/uuid": "^3.4.6", | ||
"@types/node": "^12.12.16", | ||
"mocha": "^6.2.2", | ||
"nyc": "^14.1.1", | ||
"prettier": "^1.19.1", | ||
"ts-node": "^8.5.2", | ||
"ts-node": "^8.5.4", | ||
"tslint": "^5.20.1", | ||
"tslint-config-prettier": "^1.18.0", | ||
"tslint-plugin-prettier": "^2.0.1", | ||
"typescript": "^3.7.2" | ||
"typescript": "^3.7.3" | ||
}, | ||
"dependencies": { | ||
"cucumber-messages": "7.0.0", | ||
"uuid": "^3.3.3", | ||
"commander": "^4.0.1", | ||
"cucumber-messages": "8.0.0", | ||
"source-map-support": "^0.5.16" | ||
} | ||
} |
import AstNode from './AstNode' | ||
import { messages } from 'cucumber-messages' | ||
import { messages, IdGenerator } from 'cucumber-messages' | ||
import { RuleType, TokenType } from './Parser' | ||
import Token from './Token' | ||
import { AstBuilderException } from './Errors' | ||
import { NewId } from './types' | ||
import createLocation from './cli/createLocation' | ||
@@ -12,5 +11,5 @@ | ||
private comments: messages.GherkinDocument.IComment[] | ||
private readonly newId: NewId | ||
private readonly newId: IdGenerator.NewId | ||
constructor(newId: NewId) { | ||
constructor(newId: IdGenerator.NewId) { | ||
this.newId = newId | ||
@@ -17,0 +16,0 @@ if (!newId) { |
@@ -1,63 +0,53 @@ | ||
import gherkin from '../index' | ||
import { IGherkinOptions } from '../types' | ||
import { Command } from 'commander' | ||
import packageJson from '../../package.json' | ||
import Gherkin from '../Gherkin' | ||
import { | ||
messages, | ||
ProtobufBinaryStream, | ||
ProtobufNdjsonStream, | ||
MessageToBinaryStream, | ||
MessageToNdjsonStream, | ||
IdGenerator, | ||
} from 'cucumber-messages' | ||
import { Readable } from 'stream' | ||
import { incrementing, uuid } from '../IdGenerator' | ||
import { Readable, Transform } from 'stream' | ||
import IGherkinOptions from '../IGherkinOptions' | ||
const args = process.argv.slice(2) | ||
const program = new Command() | ||
program.version(packageJson.version) | ||
program.option('--no-source', 'Do not output Source messages', false) | ||
program.option('--no-ast', 'Do not output GherkinDocument messages', false) | ||
program.option('--no-pickles', 'Do not output Pickle messages', false) | ||
program.option('--predictable-ids', 'Use predictable ids', false) | ||
program.option( | ||
'-f, --format <format>', | ||
'output format: ndjson|protobuf', | ||
'protobuf' | ||
) | ||
program.parse(process.argv) | ||
const paths = program.args | ||
const options: IGherkinOptions = { | ||
defaultDialect: 'en', | ||
includeSource: true, | ||
includeGherkinDocument: true, | ||
includePickles: true, | ||
newId: uuid(), | ||
includeSource: program.source, | ||
includeGherkinDocument: program.ast, | ||
includePickles: program.pickles, | ||
newId: program.predictableIds | ||
? IdGenerator.incrementing() | ||
: IdGenerator.uuid(), | ||
} | ||
let json = false | ||
const paths = [] | ||
while (args.length > 0) { | ||
const arg = args.shift() | ||
switch (arg) { | ||
case '--no-source': | ||
options.includeSource = false | ||
break | ||
case '--no-ast': | ||
options.includeGherkinDocument = false | ||
break | ||
case '--no-pickles': | ||
options.includePickles = false | ||
break | ||
case '--json': | ||
json = true | ||
break | ||
case '--predictable-ids': | ||
options.newId = incrementing() | ||
break | ||
default: | ||
paths.push(arg) | ||
} | ||
} | ||
const messageStream = | ||
paths.length === 0 | ||
? gherkin.fromStream((process.stdin as unknown) as Readable, options) | ||
: gherkin.fromPaths(paths, options) | ||
? Gherkin.fromStream((process.stdin as unknown) as Readable, options) | ||
: Gherkin.fromPaths(paths, options) | ||
const encodedStream = json | ||
? messageStream.pipe(new ProtobufNdjsonStream()) | ||
: messageStream.pipe( | ||
new ProtobufBinaryStream( | ||
messages.Envelope.encodeDelimited.bind(messages.Envelope) | ||
) | ||
) | ||
let encodedStream: Transform | ||
switch (program.format) { | ||
case 'ndjson': | ||
encodedStream = new MessageToNdjsonStream() | ||
break | ||
case 'protobuf': | ||
encodedStream = new MessageToBinaryStream() | ||
break | ||
default: | ||
throw new Error(`Unsupported format: ${program.format}`) | ||
} | ||
encodedStream.pipe(process.stdout) | ||
messageStream.pipe(encodedStream).pipe(process.stdout) |
@@ -88,3 +88,6 @@ import { messages } from 'cucumber-messages' | ||
function tokenLocation(token: Token) { | ||
return token.location && token.location.line && token.line && token.line.indent !== undefined | ||
return token.location && | ||
token.location.line && | ||
token.line && | ||
token.line.indent !== undefined | ||
? createLocation({ | ||
@@ -91,0 +94,0 @@ line: token.location.line, |
import { spawn, spawnSync } from 'child_process' | ||
import { messages, ProtobufMessageStream } from 'cucumber-messages' | ||
import { messages, BinaryToMessageStream } from 'cucumber-messages' | ||
import { Readable } from 'stream' | ||
import Dialect from '../Dialect' | ||
import { IGherkinOptions } from '../types' | ||
import IGherkinOptions from '../IGherkinOptions' | ||
@@ -12,5 +12,4 @@ export default class GherkinExe { | ||
private readonly envelopes: messages.IEnvelope[], | ||
private readonly options: IGherkinOptions, | ||
) { | ||
} | ||
private readonly options: IGherkinOptions | ||
) {} | ||
@@ -34,10 +33,10 @@ public dialects(): { [key: string]: Dialect } { | ||
const args = options.concat(this.paths) | ||
const gherkin = spawn(this.gherkinExe, args, { stdio: ['pipe', 'pipe', 'inherit'] }) | ||
const protobufMessageStream = new ProtobufMessageStream( | ||
messages.Envelope.decodeDelimited.bind(messages.Envelope), | ||
const gherkin = spawn(this.gherkinExe, args, { | ||
stdio: ['pipe', 'pipe', 'inherit'], | ||
}) | ||
const toMessageStream = new BinaryToMessageStream( | ||
messages.Envelope.decodeDelimited.bind(messages.Envelope) | ||
) | ||
gherkin.on('error', err => { | ||
protobufMessageStream.emit('error', err) | ||
}) | ||
gherkin.stdout.pipe(protobufMessageStream) | ||
gherkin.on('error', err => toMessageStream.emit('error', err)) | ||
gherkin.stdout.pipe(toMessageStream) | ||
for (const envelope of this.envelopes) { | ||
@@ -47,4 +46,4 @@ gherkin.stdin.write(messages.Envelope.encodeDelimited(envelope).finish()) | ||
gherkin.stdin.end() | ||
return protobufMessageStream | ||
return toMessageStream | ||
} | ||
} |
107
src/index.ts
@@ -1,104 +0,5 @@ | ||
import { gherkinOptions, IGherkinOptions } from './types' | ||
import { PassThrough, Readable } from 'stream' | ||
import ParserMessageStream from './stream/ParserMessageStream' | ||
import fs from 'fs' | ||
import SourceMessageStream from './stream/SourceMessageStream' | ||
import { messages, ProtobufMessageStream } from 'cucumber-messages' | ||
import DIALECTS from './gherkin-languages.json' | ||
import Dialect from './Dialect' | ||
import GherkinExe from './external/GherkinExe' | ||
import { uuid, incrementing } from './IdGenerator' | ||
import Gherkin from './Gherkin' | ||
import IGherkinOptions from './IGherkinOptions' | ||
export function fromStream(stream: Readable, options: IGherkinOptions = {}) { | ||
return stream | ||
.pipe(new ProtobufMessageStream(messages.Envelope.decodeDelimited)) | ||
.pipe(new ParserMessageStream(options)) | ||
} | ||
export function fromPaths( | ||
paths: string[], | ||
options: IGherkinOptions = {} | ||
): Readable { | ||
options = gherkinOptions(options) | ||
if (process.env.GHERKIN_EXECUTABLE) { | ||
return new GherkinExe( | ||
process.env.GHERKIN_EXECUTABLE, | ||
paths, | ||
[], | ||
options | ||
).messageStream() | ||
} | ||
const combinedMessageStream = new PassThrough({ | ||
writableObjectMode: true, | ||
readableObjectMode: true, | ||
}) | ||
function pipeSequentially() { | ||
const path = paths.shift() | ||
if (path !== undefined) { | ||
const parserMessageStream = new ParserMessageStream(options) | ||
parserMessageStream.on('end', () => { | ||
pipeSequentially() | ||
}) | ||
const end = paths.length === 0 | ||
fs.createReadStream(path, { encoding: 'utf-8' }) | ||
.pipe(new SourceMessageStream(path)) | ||
.pipe(parserMessageStream) | ||
.pipe( | ||
combinedMessageStream, | ||
{ end } | ||
) | ||
} | ||
} | ||
pipeSequentially() | ||
return combinedMessageStream | ||
} | ||
export function fromSources( | ||
envelopes: messages.IEnvelope[], | ||
options: IGherkinOptions = {} | ||
): Readable { | ||
options = gherkinOptions(options) | ||
if (process.env.GHERKIN_EXECUTABLE) { | ||
return new GherkinExe( | ||
process.env.GHERKIN_EXECUTABLE, | ||
[], | ||
envelopes, | ||
options | ||
).messageStream() | ||
} | ||
const combinedMessageStream = new PassThrough({ objectMode: true }) | ||
function pipeSequentially() { | ||
const envelope = envelopes.shift() | ||
if (envelope !== undefined && envelope.source) { | ||
const parserMessageStream = new ParserMessageStream(options) | ||
parserMessageStream.pipe( | ||
combinedMessageStream, | ||
{ end: envelopes.length === 0 } | ||
) | ||
parserMessageStream.on('end', pipeSequentially) | ||
parserMessageStream.end(envelope) | ||
} | ||
} | ||
pipeSequentially() | ||
return combinedMessageStream | ||
} | ||
export function dialects(): { [key: string]: Dialect } { | ||
return DIALECTS | ||
} | ||
export default { | ||
fromStream, | ||
fromPaths, | ||
fromSources, | ||
dialects, | ||
uuid, | ||
incrementing, | ||
} | ||
export default Gherkin | ||
export { IGherkinOptions } |
@@ -1,4 +0,3 @@ | ||
import { messages } from 'cucumber-messages' | ||
import { messages, IdGenerator } from 'cucumber-messages' | ||
import IGherkinDocument = messages.IGherkinDocument | ||
import { NewId } from '../types' | ||
@@ -8,3 +7,3 @@ export default function compile( | ||
uri: string, | ||
newId: NewId | ||
newId: IdGenerator.NewId | ||
) { | ||
@@ -67,3 +66,3 @@ const pickles: messages.IPickle[] = [] | ||
uri: string, | ||
newId: NewId | ||
newId: IdGenerator.NewId | ||
) { | ||
@@ -74,3 +73,5 @@ let ruleBackgroundSteps = [].concat(featureBackgroundSteps) | ||
if (stepsContainer.background) { | ||
ruleBackgroundSteps = ruleBackgroundSteps.concat(stepsContainer.background.steps) | ||
ruleBackgroundSteps = ruleBackgroundSteps.concat( | ||
stepsContainer.background.steps | ||
) | ||
} else if (stepsContainer.scenario.examples.length === 0) { | ||
@@ -107,5 +108,8 @@ compileScenario( | ||
uri: string, | ||
newId: NewId | ||
newId: IdGenerator.NewId | ||
) { | ||
const steps = scenario.steps.length === 0 ? [] : backgroundSteps.map(step => pickleStep(step, [], null, newId)) | ||
const steps = | ||
scenario.steps.length === 0 | ||
? [] | ||
: backgroundSteps.map(step => pickleStep(step, [], null, newId)) | ||
@@ -119,3 +123,3 @@ const tags = [].concat(featureTags).concat(scenario.tags) | ||
uri, | ||
sourceIds: [scenario.id], | ||
astNodeIds: [scenario.id], | ||
tags: pickleTags(tags), | ||
@@ -136,3 +140,3 @@ name: scenario.name, | ||
uri: string, | ||
newId: NewId | ||
newId: IdGenerator.NewId | ||
) { | ||
@@ -144,4 +148,6 @@ scenario.examples | ||
examples.tableBody.forEach(valuesRow => { | ||
const steps = scenario.steps.length === 0 ? | ||
[] : backgroundSteps.map(step => pickleStep(step, [], null, newId)) | ||
const steps = | ||
scenario.steps.length === 0 | ||
? [] | ||
: backgroundSteps.map(step => pickleStep(step, [], null, newId)) | ||
const tags = [] | ||
@@ -166,3 +172,3 @@ .concat(featureTags) | ||
uri, | ||
sourceIds: [scenario.id, valuesRow.id], | ||
astNodeIds: [scenario.id, valuesRow.id], | ||
name: interpolate(scenario.name, variableCells, valuesRow.cells), | ||
@@ -238,3 +244,3 @@ language, | ||
valuesRow: messages.GherkinDocument.Feature.ITableRow, | ||
newId: NewId | ||
newId: IdGenerator.NewId | ||
) { | ||
@@ -248,7 +254,7 @@ return scenario.steps.map(s => pickleStep(s, variableCells, valuesRow, newId)) | ||
valuesRow: messages.GherkinDocument.Feature.ITableRow | null, | ||
newId: NewId | ||
newId: IdGenerator.NewId | ||
) { | ||
const sourceIds = [step.id] | ||
const astNodeIds = [step.id] | ||
if (valuesRow) { | ||
sourceIds.push(valuesRow.id) | ||
astNodeIds.push(valuesRow.id) | ||
} | ||
@@ -261,3 +267,3 @@ const valueCells = valuesRow ? valuesRow.cells : [] | ||
argument: createPickleArguments(step, variableCells, valueCells), | ||
sourceIds, | ||
astNodeIds, | ||
}) | ||
@@ -273,4 +279,4 @@ } | ||
name: tag.name, | ||
sourceId: tag.id, | ||
astNodeId: tag.id, | ||
}) | ||
} |
import Parser from '../Parser' | ||
import TokenMatcher from '../TokenMatcher' | ||
import { messages } from 'cucumber-messages' | ||
import { IGherkinOptions } from '../types' | ||
import compile from '../pickles/compile' | ||
import AstBuilder from '../AstBuilder' | ||
import IGherkinOptions from '../IGherkinOptions' | ||
@@ -8,0 +8,0 @@ export default function generateMessages( |
import generateMessages from './generateMessages' | ||
import { Transform, TransformCallback } from 'stream' | ||
import { IGherkinOptions } from '../types' | ||
import { messages } from 'cucumber-messages' | ||
import IGherkinOptions from '../IGherkinOptions' | ||
@@ -6,0 +6,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
801820
10
132
19496
+ Addedcommander@^4.0.1
+ Added@types/node@20.12.11(transitive)
+ Added@types/uuid@3.4.13(transitive)
+ Addedcommander@4.1.1(transitive)
+ Addedcucumber-messages@8.0.0(transitive)
- Removeduuid@^3.3.3
- Removed@types/node@20.12.8(transitive)
- Removedcucumber-messages@7.0.0(transitive)
Updatedcucumber-messages@8.0.0