The scripts in my package.json currently looks like this:
"scripts": {
"test": "./spec/run-local-tests.sh",
"coverage": "istanbul cover jasmine-node spec",
"start": "gulp"
}
The test script runs this .sh file:
#!/bin/sh
echo "Renaming database file produced by previous test run"
mv -f 'shared-local-instance.db' 'shared-local-instance.db.previous'
echo "Starting DynamoDB"
java -Djava.library.path=./DynamoDBLocal_lib -jar dynamodb/DynamoDBLocal.jar -sharedDb &
export JAVA_PID=$!
echo "Running Tests"
./node_modules/jasmine-node/bin/jasmine-node spec
echo "Cleaning up DynamoDB - killing local instance"
kill -9 $JAVA_PID
However I now want to change my coverage
script to run the shell file:
"coverage": "istanbul cover ./spec/run-local-tests.sh"
But I then get an error that says:
echo "Renaming database file produced by previous test run"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected string
Is there a way that I can get instanbul and my shell file to run?
RTFM.
The Istanbul docs say:
(emphasis mine)
istanbul cover
needs a node script. It can't do coverage on shell scripts or any other arbitrary executable.You could write a shell script that does whatever setup/cleanup you need, then launches
istanbul cover
, and configure it thus:Or you could modify your existing script, perhaps like this:
Then call it with the environment variable set: