-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
98 lines (82 loc) · 2.17 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const { defineParameterType } = require('@cucumber/cucumber')
const { getArray, getJson, getBoolean, getDate, getDateMonthFirst, getProcessEnvWithKey } = require('./transformers');
defineParameterType({
name: 'dd-mm-yy',
regexp: /\d\d[^\d]\d\d[^\d]\d\d/,
transformer: s => getDate(s)
});
defineParameterType({
name: 'mm-dd-yy',
regexp: /\d\d[^\d]\d\d[^\d]\d\d/,
transformer: s => getDateMonthFirst(s)
});
defineParameterType({
name: 'dd-mm-yyyy',
regexp: /\d\d[^\d]\d\d[^\d]\d\d\d\d/,
transformer: s => getDate(s)
});
defineParameterType({
name: 'mm-dd-yyyy',
regexp: /\d\d[^\d]\d\d[^\d]\d\d\d\d/,
transformer: s => getDateMonthFirst(s)
});
defineParameterType({
name: 'non-space',
regexp: /[^\s]+/,
transformer: s => String(s)
});
defineParameterType({
name: 'space',
regexp: /\s+/,
transformer: s => String(s)
});
defineParameterType({
name: 'env',
regexp: /ENV\['[^']+'\]|ENV\["[^"]+"\]/,
transformer: s => getProcessEnvWithKey(s)
});
defineParameterType({
name: 'array',
regexp: /(([^,]+,)+[^,]+)/,
transformer: s => getArray(s, '')
});
defineParameterType({
name: 'int-array',
regexp: /((\d+,)+\d+)/,
transformer: s => getArray(s, 'int')
});
defineParameterType({
name: 'base2-array',
regexp: /(([01]+,)+[01]+)/,
transformer: s => getArray(s, 'base2')
});
defineParameterType({
name: 'base8-array',
regexp: /(([0-7]+,)+[0-7]+)/,
transformer: s => getArray(s, 'base8')
});
defineParameterType({
name: 'base16-array',
regexp: /(([0-9A-F]+,)+[0-9A-F]+)/,
transformer: s => getArray(s, 'base16')
});
defineParameterType({
name: 'float-array',
regexp: /(([0-9\.]+,)+[0-9\.]+)/,
transformer: s => getArray(s, 'float')
});
defineParameterType({
name: 'bool',
regexp: /true|TRUE|True|false|FALSE|False/,
transformer: s => getBoolean(s)
});
defineParameterType({
name: 'bool-array',
regexp: /(((true|TRUE|True|false|FALSE|False),)+(true|TRUE|True|false|FALSE|False))/,
transformer: s => getArray(s, 'boolean')
});
defineParameterType({
name: 'json',
regexp: /\{[^\}]*\}/,
transformer: s => getJson(s)
});