cucumber-expressions
Advanced tools
Comparing version 5.0.3 to 5.0.4
@@ -23,3 +23,3 @@ 'use strict'; | ||
var OPTIONAL_REGEXP = /\(([^)]+)\)/g; | ||
var ALTERNATIVE_WORD_REGEXP = /(\w+)((\/\w+)+)/g; | ||
var ALTERNATIVE_NON_WHITESPACE_TEXT_REGEXP = /([^\s^/]+)((\/[^\s^/]+)+)/g; | ||
@@ -38,3 +38,3 @@ this._expression = expression; | ||
expression = expression.replace(ALTERNATIVE_WORD_REGEXP, function (_, p1, p2) { | ||
expression = expression.replace(ALTERNATIVE_NON_WHITESPACE_TEXT_REGEXP, function (_, p1, p2) { | ||
return '(?:' + p1 + p2.replace(/\//g, '|') + ')'; | ||
@@ -41,0 +41,0 @@ }); |
{ | ||
"name": "cucumber-expressions", | ||
"version": "5.0.3", | ||
"version": "5.0.4", | ||
"description": "Cucumber Expressions - a simpler alternative to Regular Expressions", | ||
@@ -9,2 +9,5 @@ "main": "dist/src/index.js", | ||
"eslint": "eslint src test", | ||
"eslint-fix": "eslint --fix src test", | ||
"mocha": "mocha", | ||
"coverage": "nyc --reporter=html --reporter=text mocha", | ||
"build": "babel src --out-dir dist/src", | ||
@@ -14,6 +17,3 @@ "build-test": "babel test --out-dir dist/test", | ||
"postinstall": "node scripts/postinstall.js", | ||
"mocha": "mocha", | ||
"mocha-built": "mocha dist/test", | ||
"coverage": "nyc --reporter=html --reporter=text mocha", | ||
"precommit": "lint-staged" | ||
"mocha-built": "mocha dist/test" | ||
}, | ||
@@ -40,9 +40,9 @@ "repository": { | ||
"babel-preset-env": "^1.6.1", | ||
"eslint": "^4.10.0", | ||
"eslint": "^4.12.0", | ||
"eslint-config-eslint": "^4.0.0", | ||
"eslint-config-prettier": "^2.7.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-prettier": "^2.0.1", | ||
"mocha": "^4.0.1", | ||
"nyc": "^11.3.0", | ||
"prettier": "^1.7.4" | ||
"prettier": "^1.8.2" | ||
}, | ||
@@ -49,0 +49,0 @@ "files": [ |
@@ -12,7 +12,7 @@ const { CucumberExpressionError } = require('./errors') | ||
throw new CucumberExpressionError( | ||
`Expression ${treeRegexp.regexp} has ${argGroups.length} capture groups (${argGroups.map( | ||
g => g.value | ||
)}), but there were ${parameterTypes.length} parameter types (${parameterTypes.map( | ||
p => p.name | ||
)})` | ||
`Expression ${treeRegexp.regexp} has ${ | ||
argGroups.length | ||
} capture groups (${argGroups.map(g => g.value)}), but there were ${ | ||
parameterTypes.length | ||
} parameter types (${parameterTypes.map(p => p.name)})` | ||
) | ||
@@ -19,0 +19,0 @@ } |
@@ -13,3 +13,3 @@ const Argument = require('./argument') | ||
const OPTIONAL_REGEXP = /\(([^)]+)\)/g | ||
const ALTERNATIVE_WORD_REGEXP = /(\w+)((\/\w+)+)/g | ||
const ALTERNATIVE_NON_WHITESPACE_TEXT_REGEXP = /([^\s^/]+)((\/[^\s^/]+)+)/g | ||
@@ -29,3 +29,3 @@ this._expression = expression | ||
expression = expression.replace( | ||
ALTERNATIVE_WORD_REGEXP, | ||
ALTERNATIVE_NON_WHITESPACE_TEXT_REGEXP, | ||
(_, p1, p2) => `(?:${p1}${p2.replace(/\//g, '|')})` | ||
@@ -32,0 +32,0 @@ ) |
@@ -11,3 +11,7 @@ class CucumberExpressionError extends Error {} | ||
return new this( | ||
`parameter type with ${keyName}=${keyValue} is used by several parameter types: ${parameterTypes}, ${generatedExpressions}` | ||
`parameter type with ${keyName}=${ | ||
keyValue | ||
} is used by several parameter types: ${parameterTypes}, ${ | ||
generatedExpressions | ||
}` | ||
) | ||
@@ -14,0 +18,0 @@ } |
@@ -89,3 +89,7 @@ const ParameterType = require('./parameter_type') | ||
'There can only be one preferential parameter type per regexp. ' + | ||
`The regexp /${parameterTypeRegexp}/ is used for two preferential parameter types, {${existingParameterType.name}} and {${parameterType.name}}` | ||
`The regexp /${ | ||
parameterTypeRegexp | ||
}/ is used for two preferential parameter types, {${ | ||
existingParameterType.name | ||
}} and {${parameterType.name}}` | ||
) | ||
@@ -92,0 +96,0 @@ } |
@@ -66,3 +66,5 @@ const { CucumberExpressionError } = require('./errors') | ||
throw new CucumberExpressionError( | ||
`Single transformer unexpectedly matched 2 values - "${nonNullGroupValues[0]}" and "${nonNullGroupValues[1]}"` | ||
`Single transformer unexpectedly matched 2 values - "${ | ||
nonNullGroupValues[0] | ||
}" and "${nonNullGroupValues[1]}"` | ||
) | ||
@@ -69,0 +71,0 @@ args = [nonNullGroupValues[0]] |
@@ -22,2 +22,6 @@ /* eslint-env mocha */ | ||
it('translates alternation with non-alpha', () => { | ||
assertRegexp('I said Alpha1/Beta1', /^I said (?:Alpha1|Beta1)$/) | ||
}) | ||
it('translates parameters', () => { | ||
@@ -24,0 +28,0 @@ assertRegexp( |
@@ -55,3 +55,5 @@ /* eslint-env mocha */ | ||
err.message, | ||
`There can only be one preferential parameter type per regexp. The regexp ${CAPITALISED_WORD} is used for two preferential parameter types, {name} and {place}` | ||
`There can only be one preferential parameter type per regexp. The regexp ${ | ||
CAPITALISED_WORD | ||
} is used for two preferential parameter types, {name} and {place}` | ||
) | ||
@@ -58,0 +60,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
199853
2449