From 5da307f02e30558e484f9f5d7c774386b9c6ce87 Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Tue, 28 May 2019 17:31:18 +0100 Subject: [PATCH] Make the CommandDefinition option parameter a Partial This ensures that no code accidentally relies on them being present, and the types are then correct. Change-type: patch Signed-off-by: Cameron Diver --- automation/capitanodoc/markdown.ts | 3 +++ lib/actions/environment-variables.ts | 2 +- typings/capitano/index.d.ts | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/automation/capitanodoc/markdown.ts b/automation/capitanodoc/markdown.ts index 808e309d..974d7b09 100644 --- a/automation/capitanodoc/markdown.ts +++ b/automation/capitanodoc/markdown.ts @@ -29,6 +29,9 @@ function renderCapitanoCommand(command: CapitanoCommand): string[] { result.push('### Options'); for (const option of command.options!) { + if (option == null) { + throw new Error(`Undefined option in markdown generation!`); + } result.push( `#### ${utils.parseCapitanoOption(option)}`, option.description, diff --git a/lib/actions/environment-variables.ts b/lib/actions/environment-variables.ts index 5254e2ed..7ae16cd1 100644 --- a/lib/actions/environment-variables.ts +++ b/lib/actions/environment-variables.ts @@ -138,7 +138,7 @@ export const remove: CommandDefinition< return patterns .confirm( - options.yes, + options.yes || false, 'Are you sure you want to delete the environment variable?', ) .then(function() { diff --git a/typings/capitano/index.d.ts b/typings/capitano/index.d.ts index a2d65b44..2ce5efef 100644 --- a/typings/capitano/index.d.ts +++ b/typings/capitano/index.d.ts @@ -36,11 +36,11 @@ declare module 'capitano' { signature: string; description: string; help: string; - options?: OptionDefinition[]; + options?: Partial; permission?: 'user'; root?: boolean; primary?: boolean; - action(params: P, options: O, done: () => void): void; + action(params: P, options: Partial, done: () => void): void; } export interface Command {