Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gherkin-formatter

Package Overview
Dependencies
Maintainers
6
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gherkin-formatter - npm Package Compare versions

Comparing version 1.1.0-beta.5 to 1.1.0-beta.6

8

formatters/backgroundFormatter.js

@@ -15,7 +15,13 @@ "use strict";

const l = (0, lines_builder_1.lines)(`${background.keyword}: ${background.name}`);
if (background.preceedingComment) {
l.prepend(background.preceedingComment.text);
}
if (background.description) {
l.append((0, lines_builder_1.lines)({ trimLeft: true }, background.description));
}
if (background.descriptionComment) {
l.append(null, (0, lines_builder_1.lines)(background.descriptionComment.text));
}
if (background.steps.length > 0) {
if (background.description) {
if (background.description || background.descriptionComment) {
l.append(null);

@@ -22,0 +28,0 @@ }

@@ -7,3 +7,2 @@ "use strict";

const debug = (0, debug_1.getDebugger)("docStringFormatter");
const DOC_STRING_DELIMITER = "\"\"\"";
function format(docString) {

@@ -14,5 +13,15 @@ debug("format(docString: %s)", docString === null || docString === void 0 ? void 0 : docString.constructor.name);

}
return (0, lines_builder_1.lines)(DOC_STRING_DELIMITER, docString.content, DOC_STRING_DELIMITER).toString();
const l = (0, lines_builder_1.lines)(docString.content, docString.delimiter);
if (docString.mediaType) {
l.prepend(docString.delimiter + docString.mediaType);
}
else {
l.prepend(docString.delimiter);
}
if (docString.comment) {
l.prepend(docString.comment.text);
}
return l.toString();
}
exports.format = format;
//# sourceMappingURL=docStringFormatter.js.map

@@ -15,5 +15,11 @@ "use strict";

const l = (0, lines_builder_1.lines)(`${examples.keyword}: ${examples.name}`);
if (examples.preceedingComment) {
l.prepend(examples.preceedingComment.text);
}
if (examples.tags.length > 0) {
l.prepend((0, tagFormatter_1.format)(examples.tags, options));
}
if (examples.tagComment) {
l.prepend(examples.tagComment.text);
}
const tableRows = [examples.header, ...examples.body];

@@ -20,0 +26,0 @@ l.append((0, lines_builder_1.lines)((0, tableRowFormatter_1.format)(tableRows)));

@@ -19,8 +19,17 @@ "use strict";

const l = (0, lines_builder_1.lines)(`${feature.keyword}: ${feature.name}`);
if (feature.preceedingComment) {
l.prepend(feature.preceedingComment.text);
}
if (feature.tags.length > 0) {
l.prepend((0, tagFormatter_1.format)(feature.tags, options));
}
if (feature.tagComment) {
l.prepend(feature.tagComment.text);
}
if (feature.description) {
l.append((0, lines_builder_1.lines)({ trimLeft: true }, feature.description));
}
if (feature.descriptionComment) {
l.append((0, lines_builder_1.lines)(null, feature.descriptionComment.text));
}
if (feature.elements.length > 0) {

@@ -42,2 +51,5 @@ feature.elements.forEach((item) => {

}
if (feature.language !== 'en') {
l.prepend(`# language: ${feature.language}`);
}
return l.toString();

@@ -44,0 +56,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.format = void 0;
const lines_builder_1 = require("lines-builder");
const debug_1 = require("../debug");

@@ -12,5 +13,12 @@ const featureFormatter_1 = require("./featureFormatter");

}
return (0, featureFormatter_1.format)(document.feature, options);
const l = (0, lines_builder_1.lines)((0, featureFormatter_1.format)(document.feature, options));
if (document.startComment) {
l.prepend(document.startComment.text, null);
}
if (document.endComment) {
l.append(null, document.endComment.text);
}
return l.toString();
}
exports.format = format;
//# sourceMappingURL=gherkinDocumentFormatter.js.map

@@ -18,8 +18,17 @@ "use strict";

const l = (0, lines_builder_1.lines)(`${rule.keyword}: ${rule.name}`);
if (rule.preceedingComment) {
l.prepend(rule.preceedingComment.text);
}
if (rule.tags.length > 0) {
l.prepend((0, tagFormatter_1.format)(rule.tags, options));
}
if (rule.tagComment) {
l.prepend(rule.tagComment.text);
}
if (rule.description) {
l.append((0, lines_builder_1.lines)({ trimLeft: true }, rule.description));
}
if (rule.descriptionComment) {
l.append(null, (0, lines_builder_1.lines)(rule.descriptionComment.text));
}
if (rule.elements.length > 0) {

@@ -26,0 +35,0 @@ rule.elements.forEach((item) => {

@@ -16,9 +16,21 @@ "use strict";

const l = (0, lines_builder_1.lines)(`${scenario.keyword}: ${scenario.name}`);
if (scenario.preceedingComment) {
l.prepend(scenario.preceedingComment.text);
}
if (scenario.tags.length > 0) {
l.prepend((0, tagFormatter_1.format)(scenario.tags, options));
}
if (scenario.tagComment) {
l.prepend(scenario.tagComment.text);
}
if (scenario.description) {
l.append((0, lines_builder_1.lines)({ trimLeft: true }, scenario.description), null);
l.append((0, lines_builder_1.lines)({ trimLeft: true }, scenario.description));
}
if (scenario.descriptionComment) {
l.append(null, (0, lines_builder_1.lines)(scenario.descriptionComment.text));
}
if (scenario.steps.length > 0) {
if (scenario.description || scenario.descriptionComment) {
l.append(null);
}
const addGroups = (0, index_1.config)(options).separateStepGroups;

@@ -25,0 +37,0 @@ if (addGroups) {

@@ -15,2 +15,5 @@ "use strict";

const l = (0, lines_builder_1.lines)(`${step.keyword} ${step.text}`);
if (step.comment) {
l.prepend(step.comment.text);
}
if (step.docString) {

@@ -17,0 +20,0 @@ l.append((0, lines_builder_1.lines)((0, docStringFormatter_1.format)(step.docString)));

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.format = exports.toArray = void 0;
const lines_builder_1 = require("lines-builder");
const debug_1 = require("../debug");

@@ -17,5 +18,14 @@ const utils_1 = require("../utils");

}
return (0, utils_1.table)(tableRows.map(toArray));
const tableLines = (0, lines_builder_1.splitToLines)((0, utils_1.table)(tableRows.map(toArray)));
const result = (0, lines_builder_1.lines)();
for (let i = 0; i < tableRows.length; ++i) {
const row = tableRows[i];
if (row.comment) {
result.append(row.comment.text);
}
result.append(tableLines[i]);
}
return result.toString();
}
exports.format = format;
//# sourceMappingURL=tableRowFormatter.js.map

@@ -14,5 +14,24 @@ "use strict";

options = (0, index_1.config)(options);
return (0, lines_builder_1.lines)({ eol: options.oneTagPerLine ? null : " ", indent: "" }, ...tags.map(tag => tag.toString())).toString();
if (options.oneTagPerLine) {
const l = (0, lines_builder_1.lines)();
for (const tag of tags) {
if (tag.comment) {
l.append(tag.comment.text);
}
l.append(tag.toString());
}
return l.toString();
}
let ls = "";
for (const tag of tags) {
if (tag.comment) {
ls += `${ls ? '\n' : ''}${tag.comment.text}\n${tag.toString()}`;
}
else {
ls += `${ls ? ' ' : ''}${tag.toString()}`;
}
}
return (0, lines_builder_1.lines)(ls).toString();
}
exports.format = format;
//# sourceMappingURL=tagFormatter.js.map

6

package.json
{
"name": "gherkin-formatter",
"version": "1.1.0-beta.5",
"version": "1.1.0-beta.6",
"description": "Tool to format gherkin-ast model to gherkin string",

@@ -50,3 +50,3 @@ "main": "index.js",

"copyfiles": "^2.1.0",
"gherkin-io": "^1.0.1",
"gherkin-io": "1.2.0-beta.1",
"jest": "^27.4.7",

@@ -63,3 +63,3 @@ "jest-junit": "^13.0.0",

"gherkin-ast": "3.3.0-beta.2",
"lines-builder": "^1.2.0",
"lines-builder": "^1.3.0",
"table": "^6.8.0"

@@ -66,0 +66,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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc