Ver código fonte

ref: improve resource resolution again

Sv443 4 meses atrás
pai
commit
639ace4b6e
2 arquivos alterados com 9 adições e 4 exclusões
  1. 4 3
      assets/resources.json
  2. 5 1
      src/tools/post-build.ts

+ 4 - 3
assets/resources.json

@@ -10,9 +10,10 @@
   "css-hide_themesong_logo": "style/hideThemeSongLogo.css",
   "css-show_votes": "style/showVotes.css",
   "css-vol_slider_size": "style/volSliderSize.css",
-  "doc-changelog": {
-    "path": "/changelog.md",
-    "ref": "main"
+  "doc-license": {
+    "path": "/LICENSE.txt",
+    "ref": "$BRANCH",
+    "integrity": false
   },
   "font-cousine_ttf": "fonts/Cousine/Cousine-Regular.ttf",
   "font-cousine_woff": "fonts/Cousine/Cousine-Regular.woff",

+ 5 - 1
src/tools/post-build.ts

@@ -280,7 +280,11 @@ async function getResourceDirectives(ref: string) {
 
     for(const [name, val] of Object.entries(resources)) {
       const pathVal = typeof val === "object" ? val.path : val;
-      const hash = assetSource !== "local" && !pathVal.match(/^https?:\/\//)
+      const hash = (
+        assetSource !== "local"
+        && (typeof val === "object" && "integrity" in val ? val.integrity !== false : true)
+        && !pathVal.match(/^https?:\/\//)
+      )
         ? await getFileHashSha256(pathVal.replace(/\?.+/g, ""))
         : undefined;
       resourcesHashed[name] = typeof val === "object"