From 685c4bbc10c86dc930de086144752e435499bebf Mon Sep 17 00:00:00 2001 From: Tommy Chen Date: Fri, 30 Jul 2021 12:55:05 +0800 Subject: [PATCH] fix(changed): Fix undefined args The API of Clipanion v3 is totally different from v2. The default value of arguments are not applied in v3. --- packages/changed/src/commands/filter.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/changed/src/commands/filter.ts b/packages/changed/src/commands/filter.ts index 585f686..c1f9cb3 100644 --- a/packages/changed/src/commands/filter.ts +++ b/packages/changed/src/commands/filter.ts @@ -5,13 +5,13 @@ import listChangedWorkspaces from '../utils/listChangedWorkspaces'; export abstract class FilterCommand extends BaseCommand { @Command.String('--git-range') - public gitRange = ''; + public gitRange?: string; @Command.Array('--include') - public include: string[] = []; + public include?: string[]; @Command.Array('--exclude') - public exclude: string[] = []; + public exclude?: string[]; protected async listWorkspaces( project: Project, @@ -26,16 +26,18 @@ export abstract class FilterCommand extends BaseCommand { ); const files = stdout.split(/\r?\n/); const workspaces = listChangedWorkspaces(project, files); + const include = this.include || []; + const exclude = this.exclude || []; return workspaces.filter((ws) => { const name = structUtils.stringifyIdent(ws.locator); if (name) { - if (this.include.length && !this.include.includes(name)) { + if (include.length && !include.includes(name)) { return false; } - if (this.exclude.length && this.exclude.includes(name)) { + if (exclude.length && exclude.includes(name)) { return false; } }