2017-08-08 93 views

回答

1

這樣看來這是不可能的......使用命令yarn why node_modules/*時,紗線輸出以下消息:

參數太多,最大的1

這使我相信不可能在多個包裝上打電話yarn why

0

由於紗線似乎沒有提供檢查爲什麼所有包裝都已安裝的內置方法,因此只需調用yarn why在每個包的for循環中。

這對於幾個軟件包來說絕對是麻煩的。因此,我們需要一種簡單的方法來獲取軟件包列表。

您可以使用jq將相關性過濾到臨時文件中,或者只使用您選擇的文本編輯器並手動保存package.json的部分package.json

無論哪種方式,引號需要去;所以運行搜索,並具有下列參數替換操作:

搜索:^.+"(.+?)",$
替換:\1

現在你可以在執行yarn why一個for循環在你的臨時文件中的每個條目:

# Print json-array into installed_modules 
cat package.json | jq '.dependencies | keys' > installed_modules         

# edit/search-replace in file 
[…] 

# Loop through each module and run `yarn why` on it 
# This is fish-shell for-loop syntax. 
# You might have to look up how your shell (i.e. bash) does this 
for module in (cat installed_modules); 
    yarn why $module; 
end