Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parser(feature) {
var _this = {};
var parser = new Gherkin.Parser(new Gherkin.AstBuilder());
parser.stopAtFirstError = false;
var matcher = new Gherkin.TokenMatcher();
var scanner = new Gherkin.TokenScanner(fs.readFileSync(feature, 'UTF-8'));
try {
_this.feature = parser.parse(scanner, matcher);
_this.isSucceeded = true;
} catch (e) {
log('error in parsing feature ', feature);
_this.isSucceeded = false;
}
return _this;
}
function fromFileSync(featurePath) {
var gherkinDoc = fs.readFileSync(featurePath, 'UTF-8');
return parser.parse(
new Gherkin.TokenScanner(gherkinDoc),
new Gherkin.TokenMatcher()
);
}