yarn 是否有安装子文件夹的命令?
Is there's a command for yarn to install a subfolder?
背景:
我们在这个项目中使用了 yarn
,我们不想在编写我们的 package.json
脚本时混合使用 npm
/yarn
命令。
我有一个包含几个子文件夹的根目录。
每个人都有不同的服务。
我想在 npm install
每个服务的根文件夹中创建一个脚本。
问题:
你知道替代 npm install <folder>
的纱线是什么吗?
我正在寻找类似这个伪命令的东西:yarn <folder>
关于这个你可以使用 --cwd there is a git issue :
yarn --cwd "your/path" script
你也可以使用 cd :
cd "your/path" && yarn script
到运行单个子文件夹中的多个命令:
cd your/path && yarn && yarn some-script
到 运行 yarn install
在每个子目录上你可以做这样的事情:
"scripts": {
...
"install:all": "for D in */; do yarn --cwd \"${D}\"; done"
}
哪里
install:all
只是脚本的名字,你可以随意命名
D
是当前迭代的目录名
*/
指定要查找子目录的位置。 directory/*/
将列出 directory/
中的所有目录,directory/*/*/
将列出两级中的所有目录。
yarn -cwd
在给定文件夹中安装所有依赖项
您还可以 运行 多个命令,例如:
for D in */; do echo \"Installing stuff on ${D}\" && yarn --cwd \"${D}\"; done
将在每次迭代时打印“Installing stuff on your_subfolder/”。
背景:
我们在这个项目中使用了 yarn
,我们不想在编写我们的 package.json
脚本时混合使用 npm
/yarn
命令。
我有一个包含几个子文件夹的根目录。
每个人都有不同的服务。
我想在 npm install
每个服务的根文件夹中创建一个脚本。
问题:
你知道替代 npm install <folder>
的纱线是什么吗?
我正在寻找类似这个伪命令的东西:yarn <folder>
关于这个你可以使用 --cwd there is a git issue :
yarn --cwd "your/path" script
你也可以使用 cd :
cd "your/path" && yarn script
到运行单个子文件夹中的多个命令:
cd your/path && yarn && yarn some-script
到 运行 yarn install
在每个子目录上你可以做这样的事情:
"scripts": {
...
"install:all": "for D in */; do yarn --cwd \"${D}\"; done"
}
哪里
install:all
只是脚本的名字,你可以随意命名
D
是当前迭代的目录名
*/
指定要查找子目录的位置。 directory/*/
将列出 directory/
中的所有目录,directory/*/*/
将列出两级中的所有目录。
yarn -cwd
在给定文件夹中安装所有依赖项
您还可以 运行 多个命令,例如:
for D in */; do echo \"Installing stuff on ${D}\" && yarn --cwd \"${D}\"; done
将在每次迭代时打印“Installing stuff on your_subfolder/”。