問題描述
紗線工作區為每個運行 shell 命令 (Yarn workspaces run shell command for each)
我想使用 Yarn 的 Workspaces 功能在我的每個工作區中運行一個 shell 命令。
Yarn 支持 yarn workspaces run foo
命令,但是 foo
必須是在 package.json
中定義的腳本,而不是任意命令(例如 echo "foobar"
)。
理想情況下,我想要一個腳本,例如。“foo”:“yarn 工作區在我的頂級
。一種解決方法是向每個工作區的 package.json
中運行 echo 'foobar'”package.json
添加一個名為 foobar
的腳本,並讓頂級 package.json
委託給這些,
參考解法
方法 1:
In Yarn 3 (Berry) exec
and workspaces foreach
commands can be utilised to achieve this. For example: yarn workspaces foreach exec echo 'foobar'