Socket
Socket
Sign inDemoInstall

gherkin

Package Overview
Dependencies
66
Maintainers
4
Versions
98
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.17 to 7.0.1

.built

40

dist/src/index.d.ts

@@ -1,12 +0,30 @@

import {io} from "cucumber-messages/src/cucumber-messages";
import * as Stream from "stream";
import Source = io.cucumber.messages.Source;
export interface IGherkinOptions {
includeSource: boolean,
includeGherkinDocument: boolean,
includePickles: boolean,
/// <reference types="node" />
import { messages } from 'cucumber-messages';
import { Transform } from 'stream';
declare function fromPaths(paths: string[], options?: IGherkinOptions): Transform;
declare function fromSources(sources: messages.Source[], options?: IGherkinOptions): Transform;
declare function dialects(): {
[key: string]: Dialect;
};
interface IGherkinOptions {
defaultDialect?: string;
includeSource?: boolean;
includeGherkinDocument?: boolean;
includePickles?: boolean;
}
export function fromPaths(args: string[], options?: IGherkinOptions): Stream.Readable;
export function fromSources(args: Source[], options?: IGherkinOptions): Stream.Readable;
interface Dialect {
name: string;
native: string;
feature: readonly string[];
background: readonly string[];
rule: readonly string[];
scenario: readonly string[];
scenarioOutline: readonly string[];
examples: readonly string[];
given: readonly string[];
when: readonly string[];
then: readonly string[];
and: readonly string[];
but: readonly string[];
}
export { fromPaths, fromSources, dialects };
"use strict";
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');
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
Object.defineProperty(exports, "__esModule", { value: true });
var child_process_1 = require("child_process");
var fs_1 = require("fs");
var c21e_1 = require("c21e");
var cucumber_messages_1 = require("cucumber-messages");
var defaultOptions = {
defaultDialect: 'en',
includeSource: true,
includeGherkinDocument: true,
includePickles: true,
};
function fromPaths(paths, options) {
return new Gherkin(paths, [], options).messageStream();
if (options === void 0) { options = defaultOptions; }
return new Gherkin(paths, [], options).messageStream();
}
exports.fromPaths = fromPaths;
function fromSources(sources, options) {
return new Gherkin([], sources, options).messageStream();
if (options === void 0) { options = defaultOptions; }
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`;
exports.fromSources = fromSources;
function dialects() {
return new Gherkin([], [], {}).dialects();
}
exports.dialects = dialects;
var Gherkin = /** @class */ (function () {
function Gherkin(paths, sources, options) {
this.paths = paths;
this.sources = sources;
this.options = options;
this.options = __assign({}, defaultOptions, options);
var executables = __dirname + "/../../executables";
try {
fs_1.statSync(executables);
}
catch (err) {
// Dev mode - we're in src, not dist/src
executables = __dirname + "/../executables";
}
this.exeFile = new c21e_1.ExeFile(executables + "/gherkin-{{.OS}}-{{.Arch}}{{.Ext}}");
}
this._exeFile = new ExeFile(`${gherkinGoDir}/gherkin-go-{{.OS}}-{{.Arch}}{{.Ext}}`);
}
messageStream() {
const options = [];
if (!this._options.includeSource) options.push('--no-source');
if (!this._options.includeGherkinDocument) options.push('--no-ast');
if (!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;
}
}
Gherkin.prototype.dialects = function () {
var result = child_process_1.spawnSync(this.exeFile.fileName, ['--dialects']);
return JSON.parse(result.stdout);
};
Gherkin.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.exeFile.fileName, args);
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);
});
gherkin.stdout.pipe(protobufMessageStream);
try {
for (var _b = __values(this.sources), _c = _b.next(); !_c.done; _c = _b.next()) {
var source = _c.value;
var wrapper = cucumber_messages_1.messages.Envelope.fromObject({ source: source });
gherkin.stdin.write(cucumber_messages_1.messages.Envelope.encodeDelimited(wrapper).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 protobufMessageStream;
};
return Gherkin;
}());
//# sourceMappingURL=index.js.map
{
"name": "gherkin",
"version": "6.0.17",
"version": "7.0.1",
"description": "Gherkin parser",

@@ -11,9 +11,8 @@ "main": "dist/src/index.js",

"scripts": {
"test": "mocha test/**/*.{ts,js}",
"eslint-fix": "eslint --fix src test",
"coverage": "nyc --reporter=html --reporter=text mocha test/**/*.{ts,js}",
"build": "babel src --out-dir dist/src",
"build-test": "babel test --out-dir dist/test",
"prepublishOnly": "npm run build",
"mocha-built": "mocha dist/test"
"test": "mocha",
"lint": "tslint src/**/*.ts test/**/*.ts",
"lint-fix": "tslint --fix src/**/*.ts test/**/*.ts",
"coverage": "nyc --reporter=html --reporter=text mocha",
"build": "tsc",
"prepublishOnly": "npm run build"
},

@@ -35,24 +34,17 @@ "repository": {

"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-transform-async-to-generator": "^7.0.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@types/mocha": "^5.2.5",
"@types/node": "^11.12.1",
"eslint": "^5.3.0",
"eslint-config-eslint": "^5.0.1",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-prettier": "^3.0.0",
"mocha": "^6.0.2",
"nyc": "^13.1.0",
"prettier": "^1.8.2",
"ts-node": "^8.0.3",
"typescript": "^3.4.1"
"@types/mocha": "^5.2.7",
"@types/node": "^12.7.1",
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"prettier": "^1.18.2",
"ts-node": "^8.3.0",
"tslint": "^5.18.0",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.5.3"
},
"dependencies": {
"c21e": "^1.1.9",
"cucumber-messages": "^2.1.2"
"c21e": "1.2.1",
"cucumber-messages": "4.0.0"
}
}
{
"compilerOptions": {
"lib": ["es6"],
"declaration": true,
"target": "es5",
"lib": [
"es5",
"es6",
"es7",
"es2015",
"es2017",
"dom"
],
"sourceMap": true,
"allowJs": false,
"module": "commonjs",
"esModuleInterop": true,
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"rootDir": ".",
"outDir": "dist"
"moduleResolution": "node",
"outDir": "dist",
"downlevelIteration": true
},
"files": [
"test/GherkinTypeScriptTest.ts"
"include": [
"src/**/*",
"test/**/*"
]
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc