Skip to content

Commit 61a9f1d

Browse files
committed
fixed classpath; better error handling
1 parent fc544e6 commit 61a9f1d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Issues
7575

7676
Feel welcome to submit ideas and suggestions.
7777

78-
Related Proejcts
78+
Related Projects
7979
================
8080

8181
* [coursier](https://github.com/alexarchambault/coursier) - Pure Scala Artifact Fetching. Potential more powerful replacement for `expandcp.kts`

kscript

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if ! which expandcp.kts &> /dev/null; then
77
chmod u+x ${installDir}/expandcp.kts
88
fi
99

10-
dependencies=$(grep -F "//DEPS" $1 | head -n1 | cut -f2- -d' ' | tr ',;')
10+
dependencies=$(grep -F "//DEPS" $1 | head -n1 | cut -f2- -d' ' | tr ',;' ' ')
1111
#dependencies=" org.docopt:docopt:0.6.0-SNAPSHOT log4j:log4j:1.2.14 "
1212

1313
if [ -n "$dependencies" ]; then
@@ -28,7 +28,10 @@ if [ "${OSTYPE//[0-9.]/}" == "darwin" ]; then md5sum(){ md5 -r $1; }; fi
2828

2929
scriptCheckSum=$(md5sum $scriptFile | cut -c1-6)
3030

31-
jarDir=$(dirname ${scriptFile}) # see https://github.com/holgerbrandl/kscript/issues/5
31+
## we can use readlink here which is not functional on macos, thus:
32+
# http://stackoverflow.com/questions/3915040/bash-fish-command-to-print-absolute-path-to-a-file
33+
abspath() { echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"; }
34+
jarDir=$(dirname $(abspath ${scriptFile})) # see https://github.com/holgerbrandl/kscript/issues/5
3235
jarFile=${jarDir}/.$(basename ${scriptFile} .kts).${scriptCheckSum}.jar
3336

3437

@@ -45,6 +48,12 @@ if [ ! -f "${jarFile}" ]; then
4548

4649
kotlinc -classpath "${classpath}" -d ${jarFile} ${scriptFile}
4750

51+
if [ $? -eq 1 ]; then
52+
echo "ERROR: compilation of '$scriptFile' failed" >&2
53+
exit 1;
54+
fi
55+
56+
4857
mainJava=$(mktemp -dt kscript.XXXXXX)/Main_${className}.java
4958

5059
echo '

0 commit comments

Comments
 (0)