1
- #! /bin/sh
1
+ #! /bin/sh -ef
2
2
3
3
. ./config
4
4
5
- # Symlinks fresh KS JavaScript runtime into node_modules dir
6
- mkdir -p " $JAVASCRIPT_MODULES_DIR "
7
- if [ ! -e " $JAVASCRIPT_MODULES_DIR /kaitai-struct" ]; then
8
- ABS_JS_RUNTIME=$( pwd) /$JAVASCRIPT_RUNTIME_DIR
9
- ln -s " $ABS_JS_RUNTIME " " $JAVASCRIPT_MODULES_DIR /kaitai-struct"
5
+ if [ -f " ${JAVASCRIPT_RUNTIME_DIR} /KaitaiStream.js" ]; then
6
+ # Symlinks fresh KS JavaScript runtime into node_modules dir
7
+ ( cd " $JAVASCRIPT_RUNTIME_DIR " && npm link --ignore-scripts --production )
8
+ else
9
+ # This is normal in CI, see
10
+ # <https://github.com/kaitai-io/kaitai_struct_docker_images/blob/15da60f219b9ac24b5273093f99a159e1a048bfc/src/javascript/_common/prepare#L29-L57>.
11
+ # When testing changes to the JavaScript runtime library locally, go to
12
+ # `$JAVASCRIPT_RUNTIME_DIR` and run `npm run build` there - then the local
13
+ # runtime library will be used instead.
14
+ echo " Warning: $( realpath " $JAVASCRIPT_RUNTIME_DIR " ) /KaitaiStream.js doesn't exist (maybe you forgot to run 'npm run build'?)"
15
+ global_js_runtime_ver=$( npm ls --loglevel notice --parseable --long -g kaitai-struct | cut -d' :' -f2)
16
+ if [ -z " $global_js_runtime_ver " ]; then
17
+ echo ' => using globally installed kaitai-struct@<???>'
18
+ echo ' Error: npm package "kaitai-struct" is not installed globally, cannot continue'
19
+ exit 1
20
+ fi
21
+ echo " => using globally installed $global_js_runtime_ver "
10
22
fi
23
+ mkdir -p " $JAVASCRIPT_MODULES_DIR "
24
+ npm link kaitai-struct
25
+
11
26
# The `iconv-lite` package is assumed to be installed globally in the Docker
12
27
# image, but in Node.js 10 and older, you can only `require()` local packages,
13
28
# not global packages. `npm link` creates a symbolic link in the local
@@ -17,7 +32,7 @@ npm link iconv-lite
17
32
mkdir -p " $TEST_OUT_DIR /javascript"
18
33
NODE_PATH=compiled/javascript:helpers/javascript:$JAVASCRIPT_MODULES_DIR :$JAVASCRIPT_RUNTIME_DIR \
19
34
mocha \
20
- -R xunit spec/javascript > " $TEST_OUT_DIR /javascript/test-output-javascript.xml"
35
+ -R xunit spec/javascript > " $TEST_OUT_DIR /javascript/test-output-javascript.xml" || :
21
36
22
37
./kst-adoption-report javascript
23
38
aggregate/convert_to_json javascript " $TEST_OUT_DIR /javascript" " $TEST_OUT_DIR /javascript/ci.json"
0 commit comments