File tree Expand file tree Collapse file tree 3 files changed +20
-18
lines changed
Expand file tree Collapse file tree 3 files changed +20
-18
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { extname } from 'node:path';
66import { globSync } from 'glob' ;
77import { VFile } from 'vfile' ;
88
9- import createProgressBar from './utils/progressBar .mjs' ;
9+ import { Spinner } from './utils/spinner .mjs' ;
1010
1111/**
1212 * This method creates a simple abstract "Loader", which technically
@@ -28,18 +28,18 @@ const createLoader = () => {
2828 filePath => extname ( filePath ) === '.md'
2929 ) ;
3030
31- const progressBar = createProgressBar ( 'Loading files' ) ;
32-
33- progressBar . start ( resolvedFiles . length , 0 ) ;
31+ const spinner = new Spinner ( ) ;
32+ spinner . total = resolvedFiles . length ;
33+ spinner . start ( ) ;
3434
3535 return resolvedFiles . map ( async filePath => {
3636 const fileContents = await readFile ( filePath , 'utf-8' ) ;
37- progressBar . increment ( ) ;
37+ spinner . update ( 1 ) ;
3838
39- // normally we stop the progress bar when the loop is done
39+ // normally we stop the spinner when the loop is done
4040 // but here we return the loop so we need to stop it when the last file is loaded
41- if ( progressBar . value === progressBar . total ) {
42- progressBar . stop ( ) ;
41+ if ( spinner . progress === spinner . total ) {
42+ spinner . stop ( ) ;
4343 }
4444
4545 return new VFile ( { path : filePath , value : fileContents } ) ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import createQueries from './queries.mjs';
1111
1212import { getRemark } from './utils/remark.mjs' ;
1313import { createNodeSlugger } from './utils/slugger.mjs' ;
14- import createProgressBar from './utils/progressBar .mjs' ;
14+ import { Spinner } from './utils/spinner .mjs' ;
1515
1616/**
1717 * Creates an API doc parser for a given Markdown API doc file
@@ -179,18 +179,19 @@ const createParser = () => {
179179 // We do a Promise.all, to ensure that each API doc is resolved asynchronously
180180 // but all need to be resolved first before we return the result to the caller
181181
182- const progressBar = createProgressBar ( 'Parsing API Docs' ) ;
183- progressBar . start ( apiDocs . length , 0 ) ;
182+ const spinner = new Spinner ( ) ;
183+ spinner . start ( ) ;
184+ spinner . total = apiDocs . length ;
184185
185186 const resolvedApiDocEntries = await Promise . all (
186187 apiDocs . map ( apiDoc => {
187- progressBar . increment ( ) ;
188+ spinner . update ( 1 ) ;
188189
189190 return parseApiDoc ( apiDoc ) ;
190191 } )
191192 ) ;
192193
193- progressBar . stop ( ) ;
194+ spinner . stop ( ) ;
194195
195196 return resolvedApiDocEntries . flat ( ) ;
196197 } ;
Original file line number Diff line number Diff line change 22
33import { coerce } from 'semver' ;
44
5- import createProgressBar from './progressBar .mjs' ;
5+ import { Spinner } from '../utils/spinner .mjs' ;
66
77/**
88 * Groups all the API metadata nodes by module (`api` property) so that we can process each different file
@@ -14,19 +14,20 @@ export const groupNodesByModule = nodes => {
1414 /** @type {Map<string, Array<ApiDocMetadataEntry>> } */
1515 const groupedNodes = new Map ( ) ;
1616
17- const progressBar = createProgressBar ( groupNodesByModule . name ) ;
18- progressBar . start ( nodes . length , 0 ) ;
17+ const spinner = new Spinner ( ) ;
18+ spinner . total = nodes . length ;
19+ spinner . start ( ) ;
1920
2021 for ( const node of nodes ) {
2122 if ( ! groupedNodes . has ( node . api ) ) {
2223 groupedNodes . set ( node . api , [ ] ) ;
2324 }
2425
2526 groupedNodes . get ( node . api ) . push ( node ) ;
26- progressBar . increment ( ) ;
27+ spinner . update ( 1 ) ;
2728 }
2829
29- progressBar . stop ( ) ;
30+ spinner . stop ( ) ;
3031
3132 return groupedNodes ;
3233} ;
You can’t perform that action at this time.
0 commit comments