Skip to content

Instantly share code, notes, and snippets.

@sthefanoss
Last active February 22, 2023 21:19
Show Gist options
  • Save sthefanoss/8b329e298059b6d940aeb3b3b420dc0a to your computer and use it in GitHub Desktop.
Save sthefanoss/8b329e298059b6d940aeb3b3b420dc0a to your computer and use it in GitHub Desktop.
Adds "//@Dart=2.9" on every .dart file inside /lib folder. Useful when migrating to null-safety.
# Adds "//@dart=2.9" on every .dart file inside /lib folder.
# Useful when migrating to null-safety.
addDart29ToFile() {
echo "//@dart=2.9" > tmpfile
cat "$1" >> tmpfile
mv tmpfile "$1"
}
runFolderRecursively () {
while [ "$1" ] ; do
if [ -d "$1" ] ; then
runFolderRecursively "$1"/*
else
if [[ "$1" == *.dart ]] ; then
addDart29ToFile "$1"
fi
fi
shift
done
}
runFolderRecursively lib
@sthefanoss
Copy link
Author

@Mex978 thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment