(error: VariablesParseError)
| 94 | } |
| 95 | |
| 96 | function variablesErrorMessage(error: VariablesParseError): { title: string; message: string } { |
| 97 | switch (error.kind) { |
| 98 | case "conflict": |
| 99 | return { |
| 100 | title: "Conflicting variables flags", |
| 101 | message: "Use either --variables or --variables-file, not both.", |
| 102 | }; |
| 103 | case "read-error": |
| 104 | return { |
| 105 | title: "Could not read --variables-file", |
| 106 | message: `${error.path}: ${error.cause}`, |
| 107 | }; |
| 108 | case "parse-error": |
| 109 | return { |
| 110 | title: |
| 111 | error.source === "file" |
| 112 | ? "Invalid JSON in --variables-file" |
| 113 | : "Invalid JSON in --variables", |
| 114 | message: error.cause, |
| 115 | }; |
| 116 | case "shape-error": |
| 117 | return { |
| 118 | title: "Invalid variables payload", |
| 119 | message: 'Variables must be a JSON object (e.g. {"title":"Hello"}).', |
| 120 | }; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Resolve `--variables` / `--variables-file` into a plain object, or |
no outgoing calls
no test coverage detected