Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions elm-io.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#!/usr/bin/env bash
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <generated-js-file> <output-file>"
if [ "$#" = 3 ]; then
MAIN_MODULE=$3
elif [ "$#" = 2 ]; then
MAIN_MODULE=Main
else
echo "Usage: $0 <generated-js-file> <output-file> [<Main>]"
exit 1
fi

read -d '' handler <<- EOF
(function(){
if (typeof Elm === "undefined") { throw "elm-io config error: Elm is not defined. Make sure you call elm-io with a real Elm output file"}
if (typeof Elm.Main === "undefined" ) { throw "Elm.Main is not defined, make sure your module is named Main." };
var worker = Elm.worker(Elm.Main);
if (typeof Elm.${MAIN_MODULE} === "undefined" ) { throw "Elm.${MAIN_MODULE} is not defined, make sure your module is named Main." };
var worker = Elm.worker(Elm.${MAIN_MODULE});
})();
EOF

Expand Down