Skip to content

Commit

Permalink
Merge pull request #14 from Dcard/fix-changed-plugin
Browse files Browse the repository at this point in the history
Fix changed plugin on Yarn v3
  • Loading branch information
tommy351 committed Jul 30, 2021
2 parents 31803e1 + 685c4bb commit 9e81ae2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/changed/src/commands/filter.ts
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 9e81ae2

Please sign in to comment.