Filtreleme
Sürüm 2.13.0 ve sonrasında geçerli
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 <paket_adı>
Sürüm 2.13.0 ve sonrasında geçerli
Paket hedeflemek için kullanabileceğin iki yol vardır. Tek bir paketi bulmak için adını (@alan-adı/paket-adı
) kullanabilir veya *
karakteri ile aynı alan adına sahip birden fazla paketi hedefleyebilirsin (@alan-adı/*
).
Şu şekilde:
pnpm --filter "@babel/core" test
pnpm --filter "@babel/*" test
pnpm --filter "*core" test
Since v6.19.0:
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 <paket_adı>...
Sürüm 2.13.0 ve sonrasında geçerli
Bir paketi ve ilişkili olduğu kütüphaneleri hedeflemek için seçicinin sonuna üç nokta ekleyebilirsin: <paket_adı>...
. Örneğin aşağıdaki komut, foo
projesi ve ilişkili olduğu diğer kütüphaneler için test komutunu çalıştıracaktır:
pnpm --filter foo... test
Ayrıca, benzer isme sahip birden fazla paketi şu şekilde hedefleyebilirsin:
pnpm --filter "@babel/preset-*..." test
--filter <paket_adı>^...
Sürüm 4.4.0 ve sonrasında geçerli
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>
Sürüm 2.14.0 ve sonrasında geçerli
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>"
Sürüm 4.4.0 ve sonrasında geçerli
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
--filter ./<directory>
Sürüm 2.15.0 ve sonrasında geçerli
To only select packages under the specified directory, you may specify any relative path, typically in POSIX format.
--filter {<directory>}
Sürüm 4.7.0 ve sonrasında geçerli
Includes all projects that are under the specified directory.
It may be used with the ellipsis and chevron operators to select dependents/dependencies as well:
pnpm --filter ...{<directory>} <cmd>
pnpm --filter {<directory>}... <cmd>
pnpm --filter ...{<directory>}... <cmd>
It may also be combined with [<since>]
. For instance, to select all changed projects inside a directory:
pnpm --filter "{packages}[origin/master]" <cmd>
pnpm --filter "...{packages}[origin/master]" <cmd>
pnpm --filter "{packages}[origin/master]..." <cmd>
pnpm --filter "...{packages}[origin/master]..." <cmd>
Or you may select all packages from a directory with names matching the given pattern:
pnpm --filter "@babel/*{components}" <cmd>
pnpm --filter "@babel/*{components}[origin/master]" <cmd>
pnpm --filter "...@babel/*{components}[origin/master]" <cmd>
--filter "[<since>]"
Sürüm 4.6.0 ve sonrasında geçerli
Selects all the packages changed since the specified commit/branch. May be suffixed or prefixed with ...
to include dependencies/dependents.
For example, the next command will run tests in all changed packages since master
and on any dependent packages:
pnpm --filter "...[origin/master]" test
Excluding
Sürüm 5.8.0 ve sonrasında geçerli
Any of the filter selectors may work as exclusion operators when they have a leading "!". In zsh (and possibly other shells), "!" should be escaped: \!
.
For instance, this will run a command in all projects except for foo
:
pnpm --filter=!foo <cmd>
And this will run a command in all projects that are not under the lib
directory:
pnpm --filter=!./lib <cmd>
Multiplicity
When packages are filtered, every package is taken that matches at least one of the selectors. You can use as many filters as you want:
pnpm --filter ...foo --filter bar --filter baz... test
--filter-prod <filtering_pattern>
Sürüm 6.2.0 ve sonrasında geçerli
Acts the same a --filter
but omits devDependencies
when selecting dependency projects from the workspace.
--test-pattern <glob>
Sürüm 5.14.0 ve sonrasında geçerli
test-pattern
allows detecting whether the modified files are related to tests. If they are, the dependent packages of such modified packages are not included.
This option is useful with the "changed since" filter. For instance, the next command will run tests in all changed packages, and if the changes are in the source code of the package, tests will run in the dependent packages as well:
pnpm --filter="...[origin/master]" --test-pattern="test/*" test
--changed-files-ignore-pattern <glob>
Added in: v6.16.0
Allows to ignore changed files by glob patterns when filtering for changed projects since the specified commit/branch.
Usage example:
pnpm --filter="...[origin/master]" --changed-files-ignore-pattern="**/README.md" run build