2017-08-08 89 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