@@ -75,6 +75,8 @@ export class Loader {
75
75
let command = runningCommands . get ( this . path ) ;
76
76
if ( command ) return command ;
77
77
command = ( async ( ) => {
78
+ console . info ( `${ this . path } start` ) ;
79
+ const time = performance . now ( ) ;
78
80
const outputPath = join ( ".observablehq" , "cache" , this . targetPath ) ;
79
81
const cachePath = join ( this . sourceRoot , outputPath ) ;
80
82
const loaderStat = await maybeStat ( this . path ) ;
@@ -91,6 +93,11 @@ export class Loader {
91
93
subprocess . on ( "close" , resolve ) ;
92
94
} ) ;
93
95
await tempFd . close ( ) ;
96
+ console . info (
97
+ `${ this . path } ${ `${ code === 0 ? success ( "success" ) : error ( "error" ) } ${ outputBytes (
98
+ ( await maybeStat ( tempPath ) ) ?. size
99
+ ) } in ${ Math . floor ( performance . now ( ) - time ) } ms`} `
100
+ ) ;
94
101
if ( code === 0 ) {
95
102
await mkdir ( dirname ( cachePath ) , { recursive : true } ) ;
96
103
await rename ( tempPath , cachePath ) ;
@@ -105,3 +112,17 @@ export class Loader {
105
112
return command ;
106
113
}
107
114
}
115
+
116
+ const error = color ( 31 ) ;
117
+ const success = color ( 32 ) ;
118
+ const warning = color ( 33 ) ;
119
+
120
+ function color ( code ) {
121
+ return process . stdout . isTTY ? ( text ) => `\x1b[${ code } m${ text } \x1b[0m` : String ;
122
+ }
123
+
124
+ function outputBytes ( size ) {
125
+ if ( ! size ) return warning ( "empty output" ) ;
126
+ const e = Math . floor ( Math . log ( size ) / Math . log ( 1024 ) ) ;
127
+ return `output ${ + ( size / 1024 ** e ) . toFixed ( 2 ) } ${ [ "bytes" , "KiB" , "MiB" , "GiB" , "TiB" ] [ e ] } ` ;
128
+ }
0 commit comments