File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed
Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @team-plain/cli " : minor
3+ ---
4+
5+ Fixed error handling
Original file line number Diff line number Diff line change @@ -31,17 +31,15 @@ function handleError(message, requestId = "–") {
3131
3232async function indexUrl ( url , labelTypeIds = [ ] ) {
3333 const client = getClient ( ) ;
34-
35- const res = await client . indexDocument ( {
34+ const res = client . indexDocument ( {
3635 url,
3736 labelTypeIds,
3837 } ) ;
39-
4038 if ( res . isErr ) {
4139 handleError ( res . error . message , res . error . requestId ) ;
40+ } else {
41+ console . log ( `✅ Successfully indexed ${ url } ` ) ;
4242 }
43-
44- console . log ( `✅ Successfully indexed ${ url } ` ) ;
4543}
4644
4745program . name ( "plain" ) . version ( packageJson . version ) . description ( "Plain CLI" ) ;
@@ -74,15 +72,12 @@ program
7472 urls . push ( ...res . sites ) ;
7573 } catch ( e ) {
7674 console . err ( `Failed to fetch sitemap: ${ e . message } ` ) ;
75+ process . exit ( 1 ) ;
7776 }
7877
7978 for ( const url of urls ) {
80- const res = await indexUrl ( url , labelTypeIds ) ;
81- if ( res . isErr ) {
82- handleError ( res . error . message , res . error . requestId ) ;
83- }
79+ await indexUrl ( url , labelTypeIds ) ;
8480 }
85-
8681 console . log ( `Successfully indexed ${ urls . length } urls` ) ;
8782 } ) ;
8883
You can’t perform that action at this time.
0 commit comments