Skip to content

Commit

Permalink
fix(changed): Fix undefined args
Browse files Browse the repository at this point in the history
The API of Clipanion v3 is totally different from v2. The default value of arguments are not applied in v3.
  • Loading branch information
tommy351 committed Jul 30, 2021
1 parent 31803e1 commit 685c4bb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/changed/src/commands/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 685c4bb

Please sign in to comment.