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