Skip to content

Instantly share code, notes, and snippets.

@GAM3RG33K
Created December 1, 2021 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GAM3RG33K/47d391d694e0dd801b7821b0d15076e3 to your computer and use it in GitHub Desktop.
Save GAM3RG33K/47d391d694e0dd801b7821b0d15076e3 to your computer and use it in GitHub Desktop.
flutter clean on a collection of projects

Python program to clean all flutter projects from where the script is called

Date: 01-12-2021 Author: Harshvardhan Joshi

Requirements:

  • flutter installed & accessible from cmd
  • python3 installed & accessible from cmd
  • navigate to directory that contains multiple flutter projects

Notes:

  • This script does not include sub-directory flutter project
  • Only direct flutter projects will be cleaned

Change Log:

##0.0.1 First version of the script

# Python program to clean all flutter projects from where the script is called
# Date: 01-12-2021
# Author: Harshvardhan Joshi
# Requirements:
# - flutter installed & accessible from cmd
# - python3 installed & accessible from cmd
# - navigate to directory that contains multiple flutter projects
# Notes:
# - This script does not include sub-directory flutter project
# - Only direct flutter projects will be cleaned
import os, sys, subprocess
args = sys.argv
path = os.getcwd()
def runcmd(cmd):
p = subprocess.Popen(cmd, shell=True)
p.wait()
return
# Arguments passed
print("\nName of Python script:", sys.argv[0])
for subdir, dirs, files in os.walk(path):
for dir in dirs:
for subdir2, dirs2, files2 in os.walk(dir):
file_path = os.path.join(dir)
runcmd(['echo', 'flutter', 'clean', 'in', file_path])
runcmd(['cd', file_path, '&&', 'flutter', 'clean', '&&', 'cd', '..'])
break
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment