Created
August 5, 2016 11:03
-
-
Save dmajda/9f9f9196b05d71344f4ab5a893f12d92 to your computer and use it in GitHub Desktop.
sanity-check.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# A script I used as a sanity check that PEG.js works with a particular version | |
# of Node.js. | |
# | |
# Example usage: | |
# | |
# nvm use 6.3.1 && PEGJS_DIR=../pegjs ./sanity-check.sh | |
# | |
set -e | |
if [ -z ${PEGJS_DIR+x} ]; then | |
echo 'Set PEGJS_DIR to point to a PEG.js checkout before running this script.' | |
exit 1 | |
fi | |
rm -rf package.json node_modules arithmetics.js | |
# This prevents warnings during "npm install" that would otherwise clutter the | |
# output. | |
cat > package.json <<EOT | |
{ | |
"private": true | |
} | |
EOT | |
npm install $PEGJS_DIR | |
node_modules/.bin/pegjs -o arithmetics.js node_modules/pegjs/examples/arithmetics.pegjs | |
node <<EOT | |
var parser = require("./arithmetics"); | |
var result = parser.parse("5 + 6"); | |
console.log(result === 11 ? "OK" : "FAIL"); | |
EOT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment