forked from kaitai-io/kaitai_struct_tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-javascript
executable file
·25 lines (21 loc) · 953 Bytes
/
run-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
#!/bin/sh -ef
. ./config
# (Note: On Windows, NODE_PATH is delimited by semicolons instead of colons.)
# https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
DIVIDER=":"
if [ "$OS" = "Windows_NT" ]; then
DIVIDER=";"
fi
# Symlinks fresh KS JavaScript runtime into node_modules dir
mkdir -p "$JAVASCRIPT_MODULES_DIR"
if [ ! -e "$JAVASCRIPT_MODULES_DIR/kaitai-struct" ]; then
ABS_JS_RUNTIME=$(pwd)/$JAVASCRIPT_RUNTIME_DIR
ln -s "$ABS_JS_RUNTIME" "$JAVASCRIPT_MODULES_DIR/kaitai-struct"
fi
# 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
NODE_PATH="compiled/javascript${DIVIDER}helpers/javascript${DIVIDER}$JAVASCRIPT_MODULES_DIR" \
mocha spec/javascript