From 2f1b2fb821176a5dc3a84a056bd6281dd5ac371e Mon Sep 17 00:00:00 2001 From: yuez Date: Sun, 20 Sep 2026 13:18:21 +0800 Subject: [PATCH] build: pagecheck as standalone node script (inline escaping was fragile) --- Makefile | 11 +++++++++-- scripts/pagecheck.js | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 scripts/pagecheck.js diff --git a/Makefile b/Makefile index 62f8247..e57681e 100644 --- a/Makefile +++ b/Makefile @@ -7,15 +7,22 @@ else TARGET := commandcode.so endif -.PHONY: all build test clean lint +.PHONY: all build test clean lint pagecheck -all: build +all: build pagecheck build: CGO_ENABLED=1 go build -buildmode=c-shared -o $(TARGET) main.go +# Extract embedded JS from quota_page.go and syntax-check it with node. +# Guards against parse-time SyntaxErrors (e.g. duplicate const) that break +# the whole resource page; Go substring tests cannot catch these. +pagecheck: + @node scripts/pagecheck.js + test: go test -v -race ./... + $(MAKE) pagecheck clean: rm -f commandcode.dylib commandcode.so commandcode.dll commandcode.h diff --git a/scripts/pagecheck.js b/scripts/pagecheck.js new file mode 100644 index 0000000..9fb416f --- /dev/null +++ b/scripts/pagecheck.js @@ -0,0 +1,23 @@ +// pagecheck: syntax-check the embedded quota page JS (guards against +// parse-time SyntaxErrors like duplicate const that break the whole page). +const fs = require("fs"); +const src = fs.readFileSync("plugin/quota_page.go", "utf8"); +const m = src.match(/const QuotaPageHTML = `([\s\S]*)`/); +if (!m) { + console.error("pagecheck: QuotaPageHTML not found"); + process.exit(1); +} +const js = [...m[1].matchAll(/