Skip to content

Commit

Permalink
Use Go Embed (#70)
Browse files Browse the repository at this point in the history
* use go embed instead of blob system

* update actions and include auto.js in git
  • Loading branch information
chabad360 authored Jul 9, 2024
1 parent 5b4c05c commit fc2d5db
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 159 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test go
run: go test -race ./...
- run: npm install
working-directory: ./web
- run: npm run build --if-present
Expand All @@ -29,3 +27,5 @@ jobs:
working-directory: ./web
env:
CI: true
- name: Test go
run: go test -race ./...
1 change: 0 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ if ! [ -d web/node_modules ]; then
cd -
fi
go generate web/build.go
go generate internal/embed/embed.go
if ! command -v embedmd &> /dev/null
then
GO111MODULE=off go get github.com/campoy/embedmd
Expand Down
7 changes: 0 additions & 7 deletions internal/embed/blob.go

This file was deleted.

97 changes: 0 additions & 97 deletions internal/embed/cmd/generator/main.go

This file was deleted.

48 changes: 0 additions & 48 deletions internal/embed/embed.go

This file was deleted.

15 changes: 12 additions & 3 deletions javascript.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package live

import (
_ "embed"
"net/http"
)

var (
// JS is the contents of auto.js
//go:embed web/browser/auto.js
JS []byte

"github.com/jfyne/live/internal/embed"
// JSMap is the contents of auto.js.map
//go:embed web/browser/auto.js.map
JSMap []byte
)

// Javascript handles serving the client side
Expand All @@ -14,7 +23,7 @@ type Javascript struct {
// ServeHTTP.
func (j Javascript) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/javascript")
w.Write(embed.Get("/auto.js"))
w.Write(JS)
}

// JavascriptMap handles serving source map.
Expand All @@ -24,5 +33,5 @@ type JavascriptMap struct {
// ServeHTTP.
func (j JavascriptMap) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/json")
w.Write(embed.Get("/auto.js.map"))
w.Write(JSMap)
}
1 change: 0 additions & 1 deletion web/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
browser
dist
*.tgz
2 changes: 2 additions & 0 deletions web/browser/auto.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions web/browser/auto.js.map

Large diffs are not rendered by default.

0 comments on commit fc2d5db

Please sign in to comment.