Formally disallow flowcontrol operations from being used in bake recipes

This commit is contained in:
d98762625 2020-06-05 14:42:20 +01:00
parent 939208903a
commit 53e69835ff
4 changed files with 81 additions and 74 deletions

View file

@ -28,16 +28,22 @@ class NodeRecipe {
* @param {String | Function | Object} ing
*/
_validateIngredient(ing) {
// CASE operation name given. Find operation and validate
if (typeof ing === "string") {
const op = operations.find((op) => {
return sanitise(op.opName) === sanitise(ing);
});
if (op) {
return op;
return this._validateIngredient(op);
} else {
throw new TypeError(`Couldn't find an operation with name '${ing}'.`);
}
// CASE operation given. Check its a chef operation and check its not flowcontrol
} else if (typeof ing === "function") {
if (ing.flowControl) {
throw new TypeError(`flowControl operations like ${ing.opName} are not currently allowed in recipes for chef.bake`);
}
if (operations.includes(ing)) {
return ing;
} else {