Filtreleme
Filtreleme, girilen komutların ve parametrelerin, sadece belirtilen paketler/kütüphaneler için çalışmasını sağlamak için kullanılır.
pnpm'de, hedef paketleri isim veya ilişkilerine göre bulmak için kullanabileceğin, esnek söz dizim (syntax) yapısına sahip, "seçici (selector)" diye adlandırabileceğimiz bir tarama özelliği vardır.
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/*
).
Şu şekilde:
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
Ayrıca, benzer isme sahip birden fazla paketi şu şekilde hedefleyebilirsin:
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
--filter "...^<package_name>"
To ONLY select a package's dependents (both direct and non-direct), prefix the
package name with an ellipsis followed by a chevron. For instance, this will
run tests for all packages dependent on foo
:
pnpm --filter "...^foo" test