Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function GherkinLexer(content, gherkinListener) {
// Strip BOM
content = content.replace(/^\ufeff/g, '');
var language = 'en';
var lines = content.split('\n');
var len = lines.length;
for (var i = 0; i < len; i++) {
var line = lines[i];
if(!/^\s*#/.exec(line)) break;
var languageMatch = /^\s*#\s*language:\s*([a-zA-Z-_]+)\s*$/m.exec(line);
language = languageMatch === null ? 'en' : languageMatch[1].toLowerCase();
}
language = language.replace('-', '_');
var Lexer = gherkin.Lexer(language);
var lexer = new Lexer(gherkinListener);
this.scan = function () {
lexer.scan(content);
};
}
var fs = require('fs'),
path = require('path'),
util = require('util'),
vm = require('vm'),
stream = require('stream'),
Lexer = require('gherkin').Lexer('en'),
template = require('../template'),
sandbox = require('./sandbox');
//
// Basic gherkin feature -> mocha bdd test suite
//
// fs.createReadStream(something).pipe(new Parser).pipe(process.stdout);
//
// Basic gherkin to mocha mapping:
//
// - feature -> top-level describe()
// - scenario(s) -> inner describe(), might have one or more
// - step(s) -> it()
//
module.exports = Parser;
function lexFeature (contents, name) {
var tokens;
try {
var formatter = new Formatter();
/* eslint-disable new-cap */
var EnLexer = gherkin.Lexer('en');
/* eslint-enable new-cap */
var enLexer = new EnLexer(formatter);
enLexer.scan(contents);
tokens = formatter.done();
} catch (e) {
throw new LexFeatureError('Lexing "' + name + '" failed.');
}
return tokens;
}
function lex (file) {
try {
var formatter = new Formatter();
/* eslint-disable new-cap */
var EnLexer = gherkin.Lexer('en');
/* eslint-enable new-cap */
var enLexer = new EnLexer(formatter);
enLexer.scan(file.content);
file.tokens = formatter.done();
delete file.content;
} catch (e) {
throw new LexFeatureError('Lexing "' + file.name + '" failed.');
}
}
.then(() => {
let formatter = new FeatureLexerFormatter();
/* eslint-disable new-cap */
let EnLexer = gherkin.Lexer('en');
/* eslint-enable new-cap */
let enLexer = new EnLexer(formatter);
enLexer.scan(this.content);
this.tokens = formatter.done();
})
.catch((error) => {
featureFiles.forEach(function (file) {
try {
var formatter = new Formatter();
/* eslint-disable new-cap */
var EnLexer = gherkin.Lexer('en');
/* eslint-enable new-cap */
var enLexer = new EnLexer(formatter);
enLexer.scan(file.content);
file.tokens = formatter.done();
} catch (e) {
throw new LexFeatureError('Lexing "' + file.name + '" failed.');
}
});
}
function setTokens (file, content) {
let formatter = new FeatureLexerFormatter();
let EnLexer = gherkin.Lexer('en');
let enLexer = new EnLexer(formatter);
enLexer.scan(content);
file.tokens = formatter.done();
}