(path: string)
| 157 | } |
| 158 | |
| 159 | function parsePathToBinding(path: string): [string[], PathToBinding] { |
| 160 | if (fnRegex.test(path)) { |
| 161 | const [, name, triggersMatch, ...rawArgs] = path.match(fnRegex); |
| 162 | |
| 163 | const triggersString = (triggersMatch.startsWith('[')) |
| 164 | ? triggersMatch.substring(1, triggersMatch.length - 1) |
| 165 | : triggersMatch; |
| 166 | |
| 167 | const triggers = triggersString.split(',').map(trigger => trigger.trim()); |
| 168 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 169 | const args: any[] = []; |
| 170 | |
| 171 | if (rawArgs[0] !== undefined) { |
| 172 | rawArgs.forEach(arg => { |
| 173 | try { |
| 174 | args.push(JSON.parse(arg)); |
| 175 | } catch (e) { |
| 176 | throw new Error(`Invalid argument ${arg} in function call.`); |
| 177 | } |
| 178 | }); |
| 179 | } |
| 180 | |
| 181 | return [triggers, { name, isFunction: true, args }]; |
| 182 | } |
| 183 | |
| 184 | return [[path], { name: path, isFunction: false, args: [] }]; |
| 185 | } |
no test coverage detected