Add test for launcher.
[SquirrelJME.git] / Formula / brew-install.sh
blobc21f835a577bb3fbdcb4bac0c9644425ef446200
1 #!/bin/sh
2 # ---------------------------------------------------------------------------
3 # Multi-Phasic Applications: SquirrelJME
4 # Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 # Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
6 # ---------------------------------------------------------------------------
7 # SquirrelJME is under the GNU General Public License v3, or later.
8 # For more information see license.txt.
9 # ---------------------------------------------------------------------------
10 # Brew installation script
12 # Where is this script?
13 __exeDir="$(dirname -- "$0")"
15 # Output directory
16 __binDir="$(readlink -f -- "$1")"
17 __binBinTarget="$(readlink -f -- "$1")/squirreljme-standalone"
18 __binJarTarget="$(readlink -f -- "$1")/squirreljme-standalone.jar"
20 # Jar directory
21 __jarDir="$(readlink -f -- "$2")"
23 # Install only the first highest versioned Jar
24 mkdir -p "$__binDir"
25 find "$__jarDir" -type f | grep '\.jar$' | grep 'squirreljme-standalone' |
26 sort -r | head -n 1 | while read __jar
28 # Determine the base name of the JAR
29 __baseName="$(basename -- "$__jar")"
31 # Copy the JAR to the target
32 cp -vf "$__jar" "$__binJarTarget"
34 # Add script to launch it
35 cat << EOF > "$__binBinTarget"
36 #!/bin/sh
37 java -jar "\$(dirname -- "\$0")/squirreljme-standalone.jar" "\$@"
38 exit \$?
39 EOF
41 # Make it executable
42 chmod +x "$__binBinTarget"
43 done