From 1b0516e8b8ec0a1b07a07d281e2be29e5d72559e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 15 Aug 2023 17:11:03 -0300 Subject: data: track: indicate rereleases in util.inspect --- src/data/things/track.js | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/data/things') 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; } } -- cgit 1.3.0-6-gf8a5