Skip to content

Commit 4fa7456

Browse files

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

ci-javascript

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
#!/bin/sh
1+
#!/bin/sh -ef
22

33
. ./config
44

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"
1022
fi
23+
mkdir -p "$JAVASCRIPT_MODULES_DIR"
24+
npm link kaitai-struct
25+
1126
# The `iconv-lite` package is assumed to be installed globally in the Docker
1227
# image, but in Node.js 10 and older, you can only `require()` local packages,
1328
# not global packages. `npm link` creates a symbolic link in the local
@@ -17,7 +32,7 @@ npm link iconv-lite
1732
mkdir -p "$TEST_OUT_DIR/javascript"
1833
NODE_PATH=compiled/javascript:helpers/javascript:$JAVASCRIPT_MODULES_DIR:$JAVASCRIPT_RUNTIME_DIR \
1934
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" || :
2136

2237
./kst-adoption-report javascript
2338
aggregate/convert_to_json javascript "$TEST_OUT_DIR/javascript" "$TEST_OUT_DIR/javascript/ci.json"

0 commit comments

Comments
 (0)