vlt / docs

  • PricingBenchmarks (opens in new window)Community (opens in new window)Feedback
  • Overview
  • Attribute Selectors
  • Combinators
  • ID Selectors
  • Security Insights
    • Overview
    • :attr()
    • :has()
    • :dist()
    • :host()
    • :is()
    • :not()
    • :outdated()
    • :published()
    • :semver()
    • :spec()
    • :path()
    • :type()
    • :diff()
    • :hostname()
    • :registry()
  • Syntax
  • Examples
  • Uncommitted changes
  • Changes since a branch
  • Changes since last commit
  • Changes since a tag
  • Only workspaces that changed
  • What gets selected
  • CI use cases
  • See also
  1. Client
  2. /
  3. Selectors
  4. /
  5. Pseudo-classes
  6. /
  7. :diff()

:diff()

The :diff() pseudo-class matches packages whose files have changed between the current working tree and a specified git commitish reference. It uses git diff --name-only to determine changed files, then maps them to packages by their file path location.

Syntax

Text
:diff()
:diff(<commitish>)

When called with no argument, defaults to HEAD (uncommitted changes). Untracked files are not seen — git diff only reports tracked ones.

The comparison is two-dot: the ref's tree against your working tree, in both directions. To compare against the merge base instead — "what this branch changed", regardless of how far main has moved — use the three-dot form, :diff(main...HEAD).

Refs containing a / must be quoted, :diff("origin/main"); unquoted, the selector parser rejects the slash.

Examples

Uncommitted changes

Find packages with uncommitted changes:

Terminal
$ vlt query ':diff()'

Changes since a branch

Find packages changed since the main branch:

Terminal
$ vlt query ':diff(main)'

Changes since last commit

Terminal
$ vlt query ':diff(HEAD~1)'

Changes since a tag

Terminal
$ vlt query ':diff("v1.0.0")'

Only workspaces that changed

Terminal
$ vlt query ':workspace:diff(main)'

What gets selected

Given a monorepo where you changed files in packages/core/ and packages/utils/ since main:

Text
my-monorepo
├── packages/core/        ← files changed
├── packages/utils/       ← files changed
├── packages/cli/
└── apps/web/

:diff(main) selects:

Text
my-monorepo
├── packages/core/        ✅ has changed files
├── packages/utils/       ✅ has changed files
├── packages/cli/
└── apps/web/

CI use cases

Run tests only for changed workspaces:

Terminal
$ vlt run test --scope=':workspace:diff(main...HEAD)'

Find packages that depend on changed packages:

Terminal
$ vlt query ':has(:diff(main))'

See also

  • Affected Dependencies — testing only what a change could have broken
  • :path() — match by file path
  • :has() — find packages that depend on changed packages

Previous:type()Next:hostname()

On this page

  • Syntax
  • Examples
  • Uncommitted changes
  • Changes since a branch
  • Changes since last commit
  • Changes since a tag
  • Only workspaces that changed
  • What gets selected
  • CI use cases
  • See also
Edit this page

Deploy your package on vlt.io

Publish scoped and private packages, manage organizations and access, and give every developer and CI environment a consistent source for public and private JavaScript dependencies.

Publish now