#!/usr/bin/env python3
import os,glob

def check_and_run(file_name, command):
    currentDir = os.getcwd()
    for item in glob.glob(f"**/**{file_name}", recursive=True):
        pkgDir = os.path.dirname(item)
        print(f"[{pkgDir}] => {command}")
        if len(pkgDir) != 0:
            os.chdir(pkgDir)
        os.system(command)
        os.chdir(currentDir) 

cmd="flutter pub get"
check_and_run(file_name="pubspec.yaml", command=cmd)

