File tree Expand file tree Collapse file tree 1 file changed +19
-13
lines changed
Expand file tree Collapse file tree 1 file changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -54,22 +54,28 @@ workers_dev = true
5454` ;
5555}
5656
57- for ( const bucket of R2EXPLORER_BUCKETS . split ( "\n" ) ) {
58- const split = bucket . trim ( ) . split ( ":" ) ;
59- if ( split . length !== 2 ) {
60- console . error ( "R2EXPLORER_BUCKETS is not set correctly! ") ;
61- console . error (
62- `" ${ split } " is not in the correct format => ALIAS:BUCKET_NAME` ,
63- ) ;
64- process . exit ( 1 ) ;
65- }
57+ for ( const rawBucket of R2EXPLORER_BUCKETS . split ( "\n" ) ) {
58+ const bucket = rawBucket . trim ( ) ;
59+ if ( ! bucket ) continue ; // skip empty lines
60+ const split = bucket . split ( ": ") ;
61+ if ( split . length !== 2 && split . length !== 3 ) {
62+ console . error ( "R2EXPLORER_BUCKETS is not set correctly!" ) ;
63+ console . error ( `" ${ bucket } " is not in the correct format => ALIAS:BUCKET_NAME[:JURISDICTION]` ) ;
64+ process . exit ( 1 ) ;
65+ }
6666
67- wranglerConfig += `
67+ const [ alias , bucketName , jurisdiction ] = split ;
68+
69+ wranglerConfig += `
6870[[r2_buckets]]
69- binding = '${ split [ 0 ] } '
70- bucket_name = '${ split [ 1 ] } '
71- preview_bucket_name = '${ split [ 1 ] } '
71+ binding = '${ alias } '
72+ bucket_name = '${ bucketName } '
73+ preview_bucket_name = '${ bucketName } '
74+ ` ;
75+ if ( jurisdiction ) {
76+ wranglerConfig += `jurisdiction = '${ jurisdiction } '
7277` ;
78+ }
7379}
7480
7581console . log ( wranglerConfig ) ;
You can’t perform that action at this time.
0 commit comments