@@ -186,23 +186,23 @@ export function parsePluginReleaseArgs(argv: string[]): ParsedPluginReleaseArgs
|
186 | 186 | continue; |
187 | 187 | } |
188 | 188 | if (arg === "--plugins") { |
189 | | -selection = parsePluginReleaseSelection(argv[index + 1]); |
| 189 | +selection = parsePluginReleaseSelection(readRequiredArgValue(argv, index, arg, true)); |
190 | 190 | pluginsFlagProvided = true; |
191 | 191 | index += 1; |
192 | 192 | continue; |
193 | 193 | } |
194 | 194 | if (arg === "--selection-mode") { |
195 | | -selectionMode = parsePluginReleaseSelectionMode(argv[index + 1]); |
| 195 | +selectionMode = parsePluginReleaseSelectionMode(readRequiredArgValue(argv, index, arg)); |
196 | 196 | index += 1; |
197 | 197 | continue; |
198 | 198 | } |
199 | 199 | if (arg === "--base-ref") { |
200 | | -baseRef = argv[index + 1]; |
| 200 | +baseRef = readRequiredArgValue(argv, index, arg); |
201 | 201 | index += 1; |
202 | 202 | continue; |
203 | 203 | } |
204 | 204 | if (arg === "--head-ref") { |
205 | | -headRef = argv[index + 1]; |
| 205 | +headRef = readRequiredArgValue(argv, index, arg); |
206 | 206 | index += 1; |
207 | 207 | continue; |
208 | 208 | } |
@@ -231,6 +231,21 @@ export function parsePluginReleaseArgs(argv: string[]): ParsedPluginReleaseArgs
|
231 | 231 | return { selection, selectionMode, pluginsFlagProvided, baseRef, headRef }; |
232 | 232 | } |
233 | 233 | |
| 234 | +function readRequiredArgValue( |
| 235 | +argv: string[], |
| 236 | +index: number, |
| 237 | +flag: string, |
| 238 | +allowBlank = false, |
| 239 | +): string { |
| 240 | +const value = argv[index + 1]; |
| 241 | +const missingValue = |
| 242 | +value === undefined || value.startsWith("--") || (!allowBlank && value.trim() === ""); |
| 243 | +if (missingValue) { |
| 244 | +throw new Error(`${flag} requires a value.`); |
| 245 | +} |
| 246 | +return value; |
| 247 | +} |
| 248 | + |
234 | 249 | export function collectPublishablePluginPackageErrors( |
235 | 250 | candidate: PublishablePluginPackageCandidate, |
236 | 251 | ): string[] { |
|