« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/data/things/artwork.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/data/things/artwork.js b/src/data/things/artwork.js
index 2e8936a4..66a3c1ae 100644
--- a/src/data/things/artwork.js
+++ b/src/data/things/artwork.js
@@ -1,3 +1,5 @@
+import {inspect} from 'node:util';
+
 import {input} from '#composite';
 import Thing from '#thing';
 import {isContributionList, isDate, isFileExtension, validateReferenceList}
@@ -188,4 +190,28 @@ export class Artwork extends Thing {
 
     return this.thing.getOwnArtworkPath(this);
   }
+
+  [inspect.custom](depth, options, inspect) {
+    const parts = [];
+
+    parts.push(Thing.prototype[inspect.custom].apply(this));
+
+    if (this.thing) {
+      if (depth >= 0) {
+        const newOptions = {
+          ...options,
+          depth:
+            (options.depth === null
+              ? null
+              : options.depth - 1),
+        };
+
+        parts.push(` for ${inspect(this.thing, newOptions)}`);
+      } else {
+        parts.push(` for ${colors.blue(Thing.getReference(this.thing))}`);
+      }
+    }
+
+    return parts.join('');
+  }
 }