tile38/core/gen.sh

19 lines
415 B
Bash
Raw Normal View History

2016-03-05 02:08:16 +03:00
#!/bin/sh
set -e
cd $(dirname "${BASH_SOURCE[0]}")
export CommandsJSON=$(cat commands.json)
# replace out the json
perl -pe '
while (($i = index($_, "{{.CommandsJSON}}")) != -1) {
substr($_, $i, length("{{.CommandsJSON}}")) = $ENV{"CommandsJSON"};
}
' commands_template.go > commands.go
# remove the ignore
sed -i -e 's/\/\/ +build ignore//g' commands.go
rm -rf commands.go-e
gofmt -w commands.go