Skip to content

Commit

Permalink
feat: ✨ you can now prefix a filter with '+' to always inlcude the de…
Browse files Browse the repository at this point in the history
…pendencies of the filtered packages (see #79)
  • Loading branch information
folke committed May 14, 2020
1 parent 4f551f1 commit dd9ca3f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ $ ultra -r --filter "apps/*" pwd
...
```

When the filter is prefixed with a `+`, then all dependencies of the filtered packages will also be included.
For example, let's say you have a package "app1" that depends on "lib1", then using the filter `+app1`, will execute the command
on both `app1` **and** `lib1`, using the workspace topology.

## :package: Builds

`Ultra` automatically detects workspace dependencies, while still allowing parallel builds. Packages are build concurrently as soon as their dependencies are build (also concurrently).
Expand Down
3 changes: 2 additions & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export const RunnerOptionDefs: Record<keyof RunnerOptions, RunnerOptionDef> = {
},
filter: {
type: "string",
description: "Filter package name or directory using wildcard pattern",
description:
"Filter package name or directory using wildcard pattern. Prefix the filter with '+' to always include dependencies.",
},
root: {
type: "boolean",
Expand Down
14 changes: 11 additions & 3 deletions src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,20 @@ export class Workspace {
let ret = [...this.packages.values()]

if (filter) {
const withDeps = filter.startsWith("+")
if (withDeps) filter = filter.slice(1)
const regex: RegExp = globrex(filter, { filepath: true }).regex
ret = ret.filter(
(p) =>
const names = new Set<string>()
ret.forEach((p) => {
if (
regex.test(p.name || "") ||
regex.test(path.relative(this.root, p.root).replace(/\\/gu, "/"))
)
) {
names.add(p.name)
if (withDeps) this.getDepTree(p.name).forEach((dep) => names.add(dep))
}
})
ret = ret.filter((p) => names.has(p.name))
}
return ret.sort(
(a, b) => this.order.indexOf(a.name) - this.order.indexOf(b.name)
Expand Down

0 comments on commit dd9ca3f

Please sign in to comment.