Skip to content

Commit 6b42a7a

Browse files
committed
Consider other file types when copying
1 parent e3a2260 commit 6b42a7a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

install.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,29 @@ fi
8181

8282
existing_files=$(mpremote fs ls ":/${LIBDIR}/${PKGDIR}")
8383

84-
for py in $SRCDIR/*; do
85-
f_name=`basename $py`
86-
if [ "$ext" = "mpy" ]; then
84+
for filename in $SRCDIR/*; do
85+
f_name=`basename $filename`
86+
source_extension="${f_name##*.}"
87+
destination_extension=$source_extension
88+
89+
if [ "$ext" = "mpy" ] && [ "$source_extention" = "py" ]; then
8790
echo "Compiling $SRCDIR/$f_name to $SRCDIR/${f_name%.*}.$ext"
8891
mpy-cross "$SRCDIR/$f_name"
92+
destination_extension=$ext
8993
fi
9094

91-
if [[ $existing_files == *"${f_name%.*}.py"* ]]; then
92-
delete_file ":/${LIBDIR}/$PKGDIR/${f_name%.*}.py"
95+
# Make sure previous versions of the given file are deleted.
96+
if [[ $existing_files == *"${f_name%.*}.$source_extension"* ]]; then
97+
delete_file ":/${LIBDIR}/$PKGDIR/${f_name%.*}.$source_extension"
9398
fi
9499

95-
if [[ $existing_files == *"${f_name%.*}.mpy"* ]]; then
100+
# Check if source file has a .py extension and if a .mpy file exists on the board
101+
if [ "$source_extension" = "py" ] && [[ $existing_files == *"${f_name%.*}.mpy"* ]]; then
96102
delete_file ":/${LIBDIR}/$PKGDIR/${f_name%.*}.mpy"
97103
fi
98104

99-
copy_file $SRCDIR/${f_name%.*}.$ext ":/${LIBDIR}/$PKGDIR/${f_name%.*}.$ext"
105+
# Copy either the .py or .mpy file to the board depending on the chosen option
106+
copy_file $SRCDIR/${f_name%.*}.$destination_extension ":/${LIBDIR}/$PKGDIR/${f_name%.*}.$destination_extension"
100107
done
101108

102109
if [ "$ext" = "mpy" ]; then

0 commit comments

Comments
 (0)