File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ impl Executor for JBangExecutor {
5454 ) -> Pin < Box < dyn Future < Output = Vec < ExecutorDep > > + ' a > > {
5555 Box :: pin ( async move {
5656 let java_version = if let Some ( file_path) = input. app_args . first ( ) {
57- get_jbang_java_version_from_file ( file_path)
57+ get_jbang_java_version_from_file ( file_path) . await
5858 } else {
5959 None
6060 } ;
@@ -64,10 +64,28 @@ impl Executor for JBangExecutor {
6464 }
6565}
6666
67- pub fn get_jbang_java_version_from_file ( file_path : & str ) -> Option < String > {
67+ pub async fn get_jbang_java_version_from_file ( file_path : & str ) -> Option < String > {
6868 if let Ok ( content) = fs:: read_to_string ( file_path) {
6969 return parse_jbang_java_version ( & content) ;
7070 }
71+
72+ if file_path. starts_with ( "http://" ) || file_path. starts_with ( "https://" ) {
73+ // Gotta rewrite URLS to raw.githubusercontent.com to get the content - I believe jbang does the same internally
74+ let url = if file_path. contains ( "github.com" ) && file_path. contains ( "/blob/" ) {
75+ file_path
76+ . replace ( "/blob/" , "/" )
77+ . replace ( "github.com" , "raw.githubusercontent.com" )
78+ } else {
79+ file_path. to_string ( )
80+ } ;
81+
82+ if let Ok ( response) = reqwest:: get ( & url) . await {
83+ if let Ok ( content) = response. text ( ) . await {
84+ return parse_jbang_java_version ( & content) ;
85+ }
86+ }
87+ }
88+
7189 None
7290}
7391
You can’t perform that action at this time.
0 commit comments