Skip to content

Instantly share code, notes, and snippets.

@parkerziegler
Last active December 9, 2020 02:03
Show Gist options
  • Save parkerziegler/2c0a6a7524ed8122c191cd56bad6e73a to your computer and use it in GitHub Desktop.
Save parkerziegler/2c0a6a7524ed8122c191cd56bad6e73a to your computer and use it in GitHub Desktop.
A Bash script to run an automated upgrade from Reason (bs-platform@<8) to ReScript (bs-platform@>=8).
#!/usr/bin/env bash
function npm-do { (PATH=$(npm bin):$PATH; eval $@;) }
for file in src/*.re src/*.rei; do
[ -f "$file" ] || break
FILENAME=${file#src/}
BASENAME=${FILENAME%%.*}
cd src
if [ ${file: -3} == ".re" ]; then
npm-do bsc -format $FILENAME > "${BASENAME}.res"
elif [ ${file: -4} == ".rei" ]; then
npm-do bsc -format $FILENAME > "${BASENAME}.resi"
fi
rm $FILENAME
cd ../
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment