Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 1x 1x 1x 1x 1x 2x 2x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 2x 2x 4x 4x | const { spawn } = require('child_process') const { statSync } = require('fs') const ExeFile = require('c21e') const cm = require('cucumber-messages').io.cucumber.messages const ProtobufMessageStream = require('./ProtobufMessageStream') function fromPaths(paths, options) { return new Gherkin(paths, [], options).messageStream() } function fromSources(sources, options) { return new Gherkin([], sources, options).messageStream() } module.exports = { fromPaths, fromSources, } class Gherkin { constructor(paths, sources, options) { this._paths = paths this._sources = sources this._options = Object.assign( { includeSource: true, includeGherkinDocument: true, includePickles: true, }, options ) let gherkinGoDir = `${__dirname}/../../gherkin-go` try { statSync(gherkinGoDir) } catch (err) { // Dev mode - we're in src, not dist/src gherkinGoDir = `${__dirname}/../gherkin-go` } this._exeFile = new ExeFile( `${gherkinGoDir}/gherkin-go-{{.OS}}-{{.Arch}}{{.Ext}}` ) } messageStream() { const options = [] Iif (!this._options.includeSource) options.push('--no-source') Iif (!this._options.includeGherkinDocument) options.push('--no-ast') Iif (!this._options.includePickles) options.push('--no-pickles') const args = options.concat(this._paths) const gherkin = spawn(this._exeFile.fileName, args) const protobufMessageStream = new ProtobufMessageStream(cm.Wrapper) gherkin.on('error', err => { protobufMessageStream.emit('error', err) }) gherkin.stdout.pipe(protobufMessageStream) for (const source of this._sources) { const wrapper = new cm.Wrapper.fromObject({ source }) gherkin.stdin.write(cm.Wrapper.encodeDelimited(wrapper).finish()) } gherkin.stdin.end() return protobufMessageStream } } |