作为一名Flutter开发人员,我一直在从事许多项目。我偶尔要处理所有的问题。现在,这些项目位于我的驱动器上占用30+ GB的单个目录中。这将是一个好主意有项目的构建缓存删除,以节省一些空间。所以我想写一个脚本,循环遍历它们,并在每个文件夹中运行flutter clean
,而不是在每个项目的根目录下手动运行命令。
在Google和StackOverflow搜索之后,我想出了一个命令:
for /D %G in ("D:MyProjects*") do flutter clean "%~fG"
这个命令为每个文件夹执行flutter clean命令,如:
C:Usersvipin>flutter clean "D:MyProjectsProject1"
C:Usersvipin>flutter clean "D:MyProjectsProject2"
C:Usersvipin>flutter clean "D:MyProjectsProject3"
C:Usersvipin>flutter clean "D:MyProjectsProject4"
这应该已经工作了,因为命令状态为每个文件夹运行flutter clean
。不幸的是,它没有,并抛出错误:
C:Usersvipin>flutter clean "D:MyProjectsProject1"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
C:Usersvipin>flutter clean "D:MyProjectsProject2"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
C:Usersvipin>flutter clean "D:MyProjectsProject3"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
C:Usersvipin>flutter clean "D:MyProjectsProject4"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
...
嗯,pubspec。yaml文件在每个文件夹中都非常多,我认为flutter clean
命令需要您的提示指向项目的ROOT,如下所示:
D:MyprojectsProject1>flutter clean
现在我正在寻找一个命令/脚本任何移动命令的提示符到每个项目的根并执行命令。
很高兴你问。我对我的项目清单也有同样的想法。下面的命令将完全符合您的期望。确保从D:MyProjects
运行此程序for /d %i in (D:MyProjects*) do ( cd "%i" & flutter clean )
如果有人正在寻找macos/Unix版本:
for dir in ~/dev/* ; do (cd "$dir" && flutter clean ); done