Фільтрування
Фільтрування дозволяє обмежити команди певними підмножинами пакетів.
pnpm supports a rich selector syntax for picking packages by name or by relation.
Selectors may be specified via the --filter
(or -F
) flag:
pnpm --filter <package_selector> <command>
Matching
--filter <package_name>
To select an exact package, just specify its name (@scope/pkg
) or use a pattern to select a set of packages (@scope/*
).
Examples:
pnpm --filter "@babel/core" test
pnpm --filter "@babel/*" test
pnpm --filter "*core" test
Specifying the scope of the package is optional, so --filter=core
will pick @babel/core
if core
is not found. However, if the workspace has multiple packages with the same name (for instance, @babel/core
and @types/core
), then filtering without scope will pick nothing.
--filter <package_name>...
To select a package and its dependencies (direct and non-direct), suffix the package name with an ellipsis: <package_name>...
. For instance, the next command will run tests of foo
and all of its dependencies:
pnpm --filter foo... test
You may use a pattern to select a set of root packages:
pnpm --filter "@babel/preset-*..." test
--filter <package_name>^...
To ONLY select the dependencies of a package (both direct and non-direct), suffix the name with the aforementioned ellipsis preceded by a chevron. For instance, the next command will run tests for all of foo
's dependencies:
pnpm --filter "foo^..." test
--filter ...<package_name>
To select a package and its dependent packages (direct and non-direct), prefix the package name with an ellipsis: ...<package_name>
. For instance, this will run the tests of foo
and all packages dependent on it:
pnpm --filter ...foo test