« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateAlbumCommentaryPage.js6
-rw-r--r--src/content/dependencies/index.js9
-rw-r--r--src/find.js14
3 files changed, 22 insertions, 7 deletions
diff --git a/src/content/dependencies/generateAlbumCommentaryPage.js b/src/content/dependencies/generateAlbumCommentaryPage.js
index 5c057b80..2982b037 100644
--- a/src/content/dependencies/generateAlbumCommentaryPage.js
+++ b/src/content/dependencies/generateAlbumCommentaryPage.js
@@ -33,8 +33,10 @@ export default {
       relation('generateAlbumNavAccent', album, null);
 
     if (album.commentary) {
-      relations.albumCommentaryCover =
-        relation('generateAlbumCoverArtwork', album);
+      if (album.hasCoverArt) {
+        relations.albumCommentaryCover =
+          relation('generateAlbumCoverArtwork', album);
+      }
 
       relations.albumCommentaryContent =
         relation('transformContent', album.commentary);
diff --git a/src/content/dependencies/index.js b/src/content/dependencies/index.js
index 71802050..58bac0d2 100644
--- a/src/content/dependencies/index.js
+++ b/src/content/dependencies/index.js
@@ -177,7 +177,14 @@ export function watchContentDependencies({
       // Just skip newly created files. They'll be processed again when
       // written.
       if (spec === undefined) {
-        contentDependencies[functionName] = null;
+        // For practical purposes the file is treated as though it doesn't
+        // even exist (undefined), rather than not being ready yet (null).
+        // Apart from if existing contents of the file were erased (but not
+        // the file itself), this value might already be set (to null!) by
+        // the readdir performed at the beginning to evaluate which files
+        // should be read and processed at least once before reporting all
+        // dependencies as ready.
+        delete contentDependencies[functionName];
         return;
       }
 
diff --git a/src/find.js b/src/find.js
index c8edce98..5a249c28 100644
--- a/src/find.js
+++ b/src/find.js
@@ -34,11 +34,12 @@ export function processAllAvailableMatches(data, {
 
       const normalizedName = name.toLowerCase();
       if (normalizedName in byName) {
+        const alreadyMatchesByName = byName[normalizedName];
         byName[normalizedName] = null;
         if (normalizedName in multipleNameMatches) {
           multipleNameMatches[normalizedName].push(thing);
         } else {
-          multipleNameMatches[normalizedName] = [thing];
+          multipleNameMatches[normalizedName] = [alreadyMatchesByName, thing];
         }
       } else {
         byName[normalizedName] = thing;
@@ -97,16 +98,21 @@ function findHelper({
     const typePart = regexMatch[1];
     const refPart = regexMatch[2];
 
+    const normalizedName =
+      (typePart
+        ? null
+        : refPart.toLowerCase());
+
     const match =
       (typePart
         ? subcache.byDirectory[refPart]
-        : subcache.byName[refPart.toLowerCase()]);
+        : subcache.byName[normalizedName]);
 
     if (!match && !typePart) {
-      if (subcache.multipleNameMatches[refPart]) {
+      if (subcache.multipleNameMatches[normalizedName]) {
         return warnOrThrow(mode,
           `Multiple matches for reference "${fullRef}". Please resolve:\n` +
-          subcache.multipleNameMatches[refPart]
+          subcache.multipleNameMatches[normalizedName]
             .map(match => `- ${inspect(match)}\n`)
             .join('') +
           `Returning null for this reference.`);