| 1 | #!/usr/bin/env bash |
| 2 | BUILD_FILE="./build/game.js" |
| 3 | SRC_DIR="./src" |
| 4 | |
| 5 | printf "Build started, output file: $BUILD_FILE\n" |
| 6 | |
| 7 | if test -f "$BUILD_FILE"; then |
| 8 | unlink $BUILD_FILE |
| 9 | fi |
| 10 | |
| 11 | loop() |
| 12 | { |
| 13 | shopt -s nullglob |
| 14 | shopt -s globstar |
| 15 | |
| 16 | for file in "$@"/** |
| 17 | do |
| 18 | if [ -f "$file" ] && [ "${file##*.}" = "js" ] |
| 19 | then |
| 20 | printf "\n/*\n * Start File:\n * "$file"\n */ \n" >> "$BUILD_FILE"; |
| 21 | printf "Building "$file"\n"; |
| 22 | cat "$file" >> "$BUILD_FILE"; |
| 23 | printf "\n/*\n * End File:\n * "$file"\n */ \n" >> "$BUILD_FILE"; |
| 24 | fi |
| 25 | done |
| 26 | } |
| 27 | loop $SRC_DIR |
| 28 | printf "DONE" |