Minor changes to update.sh and build.sh for chromedp-gen

This commit is contained in:
Kenneth Shaw 2017-06-18 09:46:51 +07:00
parent fa3cf26d37
commit 59b4e8a6af
5 changed files with 27 additions and 26 deletions

View File

@ -1,30 +1,8 @@
#!/bin/bash
UPDATE=0
LASTUPDATE=0
if [ -f .last ]; then
LASTUPDATE=$(cat .last)
fi
NOW=$(date +%s)
if (( "$NOW" >= $(($LASTUPDATE + 86400*5)) )); then
UPDATE=1
fi
if [[ "$UPDATE" == 1 ]]; then
go get -u \
golang.org/x/tools/cmd/goimports \
github.com/mailru/easyjson/easyjson \
github.com/valyala/quicktemplate/qtc
date +%s > .last
fi
set -ve
go generate
gofmt -w -s templates/*.go
go build
time ./chromedp-gen $@

View File

@ -61,6 +61,8 @@ func main() {
const (
tpl = `package internal
// AUTOGENERATED. DO NOT EDIT.
import (
"fmt"
"strconv"

View File

@ -1,5 +1,7 @@
package internal
// AUTOGENERATED. DO NOT EDIT.
import (
"fmt"
"strconv"

View File

@ -6,6 +6,7 @@ package main
//go:generate go run domain-gen.go
//go:generate qtc -dir templates -ext qtpl
//go:generate gofmt -w -s templates/
import (
"bytes"

View File

@ -22,7 +22,25 @@ curl -s $JS_PROTO | base64 -d > $JS_TMP
# merge browser_protocol.json and js_protocol.json
jq -s '[.[] | to_entries] | flatten | reduce .[] as $dot ({}; .[$dot.key] += $dot.value)' $BROWSER_TMP $JS_TMP > $OUT
# convert boolean values listed as strings to real booleans
# (this is not used in favor of using the custom Bool type that correctly JSON unmarshals the value)
# left here for completeness
#perl -pi -e 's/"\s*:\s*"(true|false)"/": \1/g' $OUT
UPDATE=0
LASTUPDATE=0
if [ -f .last ]; then
LASTUPDATE=$(cat .last)
fi
NOW=$(date +%s)
if (( "$NOW" >= $(($LASTUPDATE + 86400*5)) )); then
UPDATE=1
fi
if [[ "$UPDATE" == 1 ]]; then
go get -u -d \
github.com/knq/chromedp/cmd/chromedp-gen
go get -u \
golang.org/x/tools/cmd/goimports \
github.com/mailru/easyjson/easyjson \
github.com/valyala/quicktemplate/qtc
date +%s > .last
fi