Skip to content

Commit

Permalink
Throw on unsupported features of {%}
Browse files Browse the repository at this point in the history
  • Loading branch information
voxpelli committed May 14, 2024
1 parent 3dfb9c6 commit f5b8e98
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const runTasks = require('./run-tasks')
// ------------------------------------------------------------------------------

const ARGS_PATTERN = /\{(!)?([*@%]|\d+)([^}]+)?}/g
const ARGS_UNPACK_PATTERN = /\{(!)?(%)([^}]+)?}/g
const ARGS_UNPACK_PATTERN = /\{(!)?([%])([^}]+)?}/g

/**
* Converts a given value to an array.
Expand Down Expand Up @@ -52,7 +52,12 @@ function applyArguments (patterns, args) {
const result = []
for (let i = 0, length = args.length; i < length; i++) {
const argPosition = i + 1
result.push(pattern.replace(ARGS_UNPACK_PATTERN, () => `{${argPosition}}`))
result.push(pattern.replace(ARGS_UNPACK_PATTERN, (whole, indirectionMark, id, options) => {
if (indirectionMark != null || options != null || id !== '%') {
throw Error(`Invalid Placeholder: ${whole}`)
}
return `{${argPosition}}`
}))
}
return result
}
Expand Down

0 comments on commit f5b8e98

Please sign in to comment.