Skip to content

Commit

Permalink
feat: filtering by location including deps
Browse files Browse the repository at this point in the history
close #1651
  • Loading branch information
zkochan committed Jan 5, 2020
1 parent 6abed4b commit 1b274bd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/common-cli-options-help/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export const FILTERING = {
description: 'Includes all packages that are under the current working directory',
name: '--filter .',
},
{
description: 'Includes all projects that are under the specified directory. Can be used with "..." to select dependents/dependencies as well',
name: '--filter {<dir>}',
},
{
description: 'Includes all packages changed since the specified commit/branch. E.g.: [master], [HEAD~2]. It may be used together with "...". So, for instance, ...[HEAD~1] selects all packages changed in the last commit and their dependents',
name: '--filter [<since>]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ export default (rawSelector: string, prefix: string): PackageSelector => {
rawSelector = rawSelector.substr(1)
}
}
if (rawSelector.startsWith('{') && rawSelector.endsWith('}')) {
return {
excludeSelf,
includeDependencies,
includeDependents,
parentDir: path.join(prefix, rawSelector.substr(1, rawSelector.length - 2)),
}
}
if (rawSelector.startsWith('[') && rawSelector.endsWith(']')) {
return {
diff: rawSelector.substr(1, rawSelector.length - 2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const fixtures: Array<[string, PackageSelector]> = [
'../foo',
{ excludeSelf: false, parentDir: path.resolve('../foo') },
],
[
'...{./foo}',
{ excludeSelf: false, includeDependencies: false, includeDependents: true, parentDir: path.resolve('foo') },
],
[
'.',
{ excludeSelf: false, parentDir: process.cwd() },
Expand Down

0 comments on commit 1b274bd

Please sign in to comment.