spago icon indicating copy to clipboard operation
spago copied to clipboard

Be able to inject build meta data into the compiled result

Open stacycurl opened this issue 5 years ago • 0 comments

Scenario: I want to show the version of the current code, or the time it was built, the git branch, spago version, etc.

A workaround I've applied manually is to add this to my code:

BuildInfo  { timestamp ∷ Int }
buildInfo = BuildInfo { timestamp: 123345 }

and then commit unholy acts using sed on the resulting js

#!/bin/bash
JS_FILE=output/Build/index.js
TIMESTAMP=$(date +"%s")
sed -i "" "s/timestamp:[^,]*/timestamp: $TIMESTAMP/g" $JS_FILE

and place that before invoking spago.

Example from Scala: https://github.com/sbt/sbt-buildinfo.

stacycurl avatar Mar 23 '20 14:03 stacycurl