#!/bin/sh

embed_bin_path=/tmp/gonicembed
assets_path=server/assets

# only build once for some slightly faster live page reloading
if ! test -e "$embed_bin_path"; then
    go build \
        -o "$embed_bin_path" \
        cmd/gonicembed/main.go
fi

find $assets_path/ \
    -type f \
    ! -name '*.go' \
    -exec "$embed_bin_path" \
        -out-path $assets_path/assets_gen.go \
        -package-name assets \
        -assets-var-name Bytes \
        -asset-path-prefix $assets_path/ \
        {} +
