gherkin
Version:
65 lines • 2.68 kB
JavaScript
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
var child_process_1 = require("child_process");
var cucumber_messages_1 = require("cucumber-messages");
var GherkinExe = /** @class */ (function () {
function GherkinExe(gherkinExe, paths, envelopes, options) {
this.gherkinExe = gherkinExe;
this.paths = paths;
this.envelopes = envelopes;
this.options = options;
}
GherkinExe.prototype.dialects = function () {
var result = child_process_1.spawnSync(this.gherkinExe, ['--dialects']);
return JSON.parse(result.stdout);
};
GherkinExe.prototype.messageStream = function () {
var e_1, _a;
var options = ['--default-dialect', this.options.defaultDialect];
if (!this.options.includeSource) {
options.push('--no-source');
}
if (!this.options.includeGherkinDocument) {
options.push('--no-ast');
}
if (!this.options.includePickles) {
options.push('--no-pickles');
}
var args = options.concat(this.paths);
var gherkin = child_process_1.spawn(this.gherkinExe, args, {
stdio: ['pipe', 'pipe', 'inherit'],
});
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 {
for (var _b = __values(this.envelopes), _c = _b.next(); !_c.done; _c = _b.next()) {
var envelope = _c.value;
gherkin.stdin.write(cucumber_messages_1.messages.Envelope.encodeDelimited(envelope).finish());
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
gherkin.stdin.end();
return toMessageStream;
};
return GherkinExe;
}());
exports.default = GherkinExe;
//# sourceMappingURL=GherkinExe.js.map
;