#!/usr/bin/env bash

gleam new project --skip-git > /dev/null
mkdir project/build
cp /piston/packages/gleam/0.27.0/project/manifest.toml project/manifest.toml
cp /piston/packages/gleam/0.27.0/project/build/packages* project/build -r 2> /dev/null

cat $1 > project/src/project.gleam

# Compile args need to be read by run
shift
echo "$@" > compile_args

cd project
# Awk is used to remove lines from the output that don't help for the piston output.
gleam build "$@" | awk "NR>=4"