11import * as fs from "node:fs" ;
22import * as path from "node:path" ;
3- import { fetchMetadata } from "@fluffylabs/links-metadata" ;
3+ import { type Metadata , fetchMetadata } from "@fluffylabs/links-metadata" ;
44import { program } from "commander" ;
55import fastGlob from "fast-glob" ;
66import ignore from "ignore" ;
@@ -9,6 +9,10 @@ import { generateNotes } from "./notes";
99import { type Report , printReport } from "./report" ;
1010import { scan } from "./scan" ;
1111
12+ const TIME_GLOB = "resolving glob patterns" ;
13+ const TIME_IGNORE = "resolving ignore patterns" ;
14+ const TIME_METADATA = "fetching metadata" ;
15+
1216main ( ) . catch ( ( err : unknown ) => {
1317 console . error ( `🚨 ${ err } ` ) ;
1418 process . exit ( 255 ) ;
@@ -26,10 +30,17 @@ async function main() {
2630 . option ( "--fix" , "Alias for --write." )
2731 . option ( "--generate-notes <file.json>" , "Generate notes for the Gray Paper Reader" )
2832 . action ( async ( paths , options ) => {
29- let files = await fastGlob ( paths ) ;
33+ console . time ( TIME_GLOB ) ;
34+ let files = [ ] ;
35+ try {
36+ files = await fastGlob ( paths ) ;
37+ } finally {
38+ console . timeEnd ( TIME_GLOB ) ;
39+ }
3040 const globExpandedFileCount = files . length ;
3141
3242 if ( options . ignoreFile ) {
43+ console . time ( TIME_IGNORE ) ;
3344 let ignorePatterns : string [ ] ;
3445
3546 try {
@@ -54,11 +65,18 @@ async function main() {
5465 }
5566 } ) ;
5667 }
68+ console . timeEnd ( TIME_IGNORE ) ;
5769 }
5870
5971 console . info ( ) ;
6072
61- const metadata = await fetchMetadata ( ) ;
73+ console . time ( TIME_METADATA ) ;
74+ let metadata : Metadata | null = null ;
75+ try {
76+ metadata = await fetchMetadata ( ) ;
77+ } finally {
78+ console . timeEnd ( TIME_METADATA ) ;
79+ }
6280
6381 const label = `scanning ${ files . length } ${ options . ignoreFile ? ` (${ globExpandedFileCount - files . length } ignored)` : "" } ` ;
6482 console . time ( label ) ;
0 commit comments