篩選
篩選功能允許您將命令限制為特定的套件子集合。
pnpm 支援豐富多元的選取器語法,可使用名稱或關係選取套件。
Selectors may be specified via the --filter
(or -F
) flag:
pnpm --filter <package_selector> <command>
比對
--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 --篩選 "@babel/core" 測試
pnpm --篩選 "@babel/*" 測試
pnpm --篩選 "*core" 測試
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
您可以使用模式來選擇一組根封裝:
pnpm --filter "@babel/preset-*..." test
--filter <package_name>^...
若要僅選取封裝的相依項 (直接和非直接),
請以前述的省略符號搭配>形箭號作為名稱尾碼。 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>"
若要僅選擇封裝的相依項 (直接和非直接),請以省略符號之後跟隨>形箭號
作為封裝名稱首碼。 For instance, this will
run tests for all packages dependent on foo
:
pnpm --filter "...^foo" test
--filter ./<glob>
, --filter {<glob>}
相對於當前工作目錄相符專案的 Glob 模式。
pnpm --filter "./packages/**" <cmd>