Minor changes to update.sh and build.sh for chromedp-gen
This commit is contained in:
parent
fa3cf26d37
commit
59b4e8a6af
|
@ -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 $@
|
||||
|
|
|
@ -61,6 +61,8 @@ func main() {
|
|||
const (
|
||||
tpl = `package internal
|
||||
|
||||
// AUTOGENERATED. DO NOT EDIT.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package internal
|
||||
|
||||
// AUTOGENERATED. DO NOT EDIT.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user