2323# {{ spec.title | caseUcfirst }} executable file path
2424{{ spec.title | upper }}_EXECUTABLE_FILEPATH=" ${{ spec.title | upper } }_INSTALL_DIR/${{ spec.title | upper } }_EXECUTABLE_NAME"
2525
26+ # {{ spec.title | caseUcfirst }} CLI temp name
27+ {{ spec.title | upper }}_TEMP_NAME=temp
28+
2629# {{ spec.title | caseUcfirst }} CLI image name
2730{{ spec.title | upper }}_CLI_IMAGE_NAME={{ spec.title | lower }}/cli
2831
124127
125128# Check if the command is in the whitelist
126129if [[ ! " ${allowList[@]} " =~ " ${1} " ]]; then
127- echo "\nLooks like a crazy hamster 🐹 flipped a bit.\n\nUse {{ language.params.executableName }} help for a list of supported commands."
130+ printf "\nLooks like a crazy hamster 🐹 flipped a bit.\n\nUse {{ language.params.executableName }} help for a list of supported commands.\n "
128131 exit 1
129132fi
130133
@@ -138,30 +141,30 @@ for x in "${@}" ; do
138141 _args=$_args" "$x
139142done
140143
141- bash -c "docker run -i --rm --volume {{ spec.title | lower }}-cli:/usr/local/code/app/.preferences/ --volume $(pwd):/usr/local/code/files:rw --network host ' ${{ spec.title | upper } }_CLI_IMAGE_NAME:${{ spec.title | upper } }_CLI_IMAGE_VERSION' $_args" ' > ${{ spec.title | upper } }_EXECUTABLE_NAME
144+ bash -c "docker run -i --rm --volume {{ spec.title | lower }}-cli:/usr/local/code/app/.preferences/ --volume $(pwd):/usr/local/code/files:rw --network host ' ${{ spec.title | upper } }_CLI_IMAGE_NAME:${{ spec.title | upper } }_CLI_IMAGE_VERSION' $_args" ' > ${{ spec.title | upper } }_TEMP_NAME
142145
143146 printf " ${GREEN} 🚧 Setting Permissions ${NC} \n"
144- chmod +x ${{ spec.title | upper } }_EXECUTABLE_NAME
147+ chmod +x ${{ spec.title | upper } }_TEMP_NAME
145148 if [ $? -ne 0 ]; then
146149 printf " ${RED} ❌ Failed to set permissions ... ${NC} \n"
147150 exit 1
148151 fi
149152 printSuccess
150153
151- printf " ${GREEN} 📝 Copying file to ${{ spec.title | upper } }_EXECUTABLE_FILEPATH ... ${NC} \n"
152- runAsRoot cp ${{ spec.title | upper } }_EXECUTABLE_NAME ${{ spec.title | upper } }_EXECUTABLE_FILEPATH
154+ printf " ${GREEN} 📝 Copying temporary file to ${{ spec.title | upper } }_EXECUTABLE_FILEPATH ... ${NC} \n"
155+ runAsRoot cp ${{ spec.title | upper } }_TEMP_NAME ${{ spec.title | upper } }_EXECUTABLE_FILEPATH
153156 if [ $? -ne 0 ]; then
154- printf " ${RED} ❌ Failed to copy file to ${{ spec.title | upper } }_EXECUTABLE_FILEPATH ... ${NC} \n"
157+ printf " ${RED} ❌ Failed to copy temporary file to ${{ spec.title | upper } }_EXECUTABLE_FILEPATH ... ${NC} \n"
155158 exit 1
156159 fi
157160 printSuccess
158161}
159162
160163cleanup () {
161164 echo " 🧹 Cleaning up mess ... "
162- rm ${{ spec.title | upper } }_EXECUTABLE_NAME
165+ rm ${{ spec.title | upper } }_TEMP_NAME
163166 if [ $? -ne 0 ]; then
164- printf " ${RED} ❌ Failed to remove ${{ spec.title | upper } }_EXECUTABLE_NAME ... ${NC} \n"
167+ printf " ${RED} ❌ Failed to remove temporary file ... ${NC} \n"
165168 exit 1
166169 fi
167170 printSuccess
0 commit comments