File tree 1 file changed +47
-0
lines changed
1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1
1
export const DATA_ALBUM_DIRECTORY = 'album' ;
2
2
3
3
import * as path from 'node:path' ;
4
+ import { inspect } from 'node:util' ;
4
5
6
+ import CacheableObject from '#cacheable-object' ;
7
+ import { colors } from '#cli' ;
5
8
import { input } from '#composite' ;
6
9
import find from '#find' ;
7
10
import { traverse } from '#node-utils' ;
@@ -578,4 +581,48 @@ export class TrackSection extends Thing {
578
581
} ,
579
582
} ,
580
583
} ;
584
+
585
+ [ inspect . custom ] ( depth ) {
586
+ const parts = [ ] ;
587
+
588
+ parts . push ( Thing . prototype [ inspect . custom ] . apply ( this ) ) ;
589
+
590
+ if ( depth >= 0 ) {
591
+ let album = null ;
592
+ try {
593
+ album = this . album ;
594
+ } catch { }
595
+
596
+ let first = null ;
597
+ try {
598
+ first = this . startIndex ;
599
+ } catch { }
600
+
601
+ let length = null ;
602
+ try {
603
+ length = this . tracks . length ;
604
+ } catch { }
605
+
606
+ album ??= CacheableObject . getUpdateValue ( this , 'ownAlbumData' ) ?. [ 0 ] ;
607
+
608
+ if ( album ) {
609
+ const albumName = album . name ;
610
+ const albumIndex = album . trackSections . indexOf ( this ) ;
611
+
612
+ const num =
613
+ ( albumIndex === - 1
614
+ ? 'indeterminate position'
615
+ : `#${ albumIndex + 1 } ` ) ;
616
+
617
+ const range =
618
+ ( albumIndex >= 0 && first !== null && length !== null
619
+ ? `: ${ first + 1 } -${ first + length + 1 } `
620
+ : '' ) ;
621
+
622
+ parts . push ( ` (${ colors . yellow ( num + range ) } in ${ colors . green ( albumName ) } )` ) ;
623
+ }
624
+ }
625
+
626
+ return parts . join ( '' ) ;
627
+ }
581
628
}
You can’t perform that action at this time.
0 commit comments