« get me outta code hell

data: track: indicate rereleases in util.inspect - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-08-15 17:11:03 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-08-15 17:11:03 -0300
commit1b0516e8b8ec0a1b07a07d281e2be29e5d72559e (patch)
tree5a074df7d67b2d09509fc98b99a2820bb1527f98 /src/data
parent886c6d1d30b6d445193a2d3379359b31b1448834 (diff)
data: track: indicate rereleases in util.inspect
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/track.js32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/data/things/track.js b/src/data/things/track.js
index a0a4ff41..98a9fdd1 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -376,15 +376,35 @@ export class Track extends Thing {
   [inspect.custom]() {
     const base = Thing.prototype[inspect.custom].apply(this);
 
+    const rereleasePart =
+      (this.originalReleaseTrackByRef
+        ? `${color.yellow('[rerelease]')} `
+        : ``);
+
     const {album, dataSourceAlbum} = this;
-    const albumName = album ? album.name : dataSourceAlbum?.name;
+
+    const albumName =
+      (album
+        ? album.name
+        : dataSourceAlbum?.name);
+
     const albumIndex =
       albumName &&
-      (album ? album.tracks.indexOf(this) : dataSourceAlbum.tracks.indexOf(this));
-    const trackNum = albumIndex === -1 ? '#?' : `#${albumIndex + 1}`;
+        (album
+          ? album.tracks.indexOf(this)
+          : dataSourceAlbum.tracks.indexOf(this));
+
+    const trackNum =
+      albumName &&
+        (albumIndex === -1
+          ? '#?'
+          : `#${albumIndex + 1}`);
+
+    const albumPart =
+      albumName
+        ? ` (${color.yellow(trackNum)} in ${color.green(albumName)})`
+        : ``;
 
-    return albumName
-      ? base + ` (${color.yellow(trackNum)} in ${color.green(albumName)})`
-      : base;
+    return rereleasePart + base + albumPart;
   }
 }