File tree Expand file tree Collapse file tree 3 files changed +38
-5
lines changed Expand file tree Collapse file tree 3 files changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -380,7 +380,7 @@ fn get_unbundle_command() -> Command {
380
380
. default_value ( "./" ) ,
381
381
)
382
382
. arg (
383
- arg ! ( --"eszip" <DIR >)
383
+ arg ! ( --"eszip" <Path >)
384
384
. help ( "Path of eszip to extract" )
385
385
. required ( true ) ,
386
386
)
Original file line number Diff line number Diff line change @@ -1196,8 +1196,31 @@ pub async fn extract_eszip(payload: ExtractEszipPayload) -> bool {
1196
1196
if let Some ( lowest_path) =
1197
1197
deno:: util:: path:: find_lowest_path ( & file_specifiers)
1198
1198
{
1199
- extract_modules ( & eszip, & file_specifiers, & lowest_path, & output_folder)
1200
- . await ;
1199
+ let targets = eszip
1200
+ . specifiers ( )
1201
+ . iter ( )
1202
+ . filter ( |it| it. starts_with ( "static:" ) )
1203
+ . cloned ( )
1204
+ . collect :: < Vec < _ > > ( ) ;
1205
+
1206
+ {
1207
+ let mut modules = eszip. eszip . modules . 0 . lock ( ) . unwrap ( ) ;
1208
+ for asset in targets {
1209
+ let url = Url :: parse ( & asset) . unwrap ( ) ;
1210
+ modules. insert (
1211
+ format ! ( "file://{}" , url. path( ) ) ,
1212
+ EszipV2Module :: Redirect { target : asset } ,
1213
+ ) ;
1214
+ }
1215
+ }
1216
+
1217
+ extract_modules (
1218
+ & eszip,
1219
+ & extract_file_specifiers ( & eszip) ,
1220
+ & lowest_path,
1221
+ & output_folder,
1222
+ )
1223
+ . await ;
1201
1224
true
1202
1225
} else {
1203
1226
panic ! ( "Path seems to be invalid" ) ;
Original file line number Diff line number Diff line change
1
+ use std:: borrow:: Cow ;
1
2
use std:: fs:: File ;
2
3
use std:: io:: Write ;
3
4
use std:: path:: Path ;
@@ -35,13 +36,22 @@ fn ensure_unix_relative_path(path: &Path) -> &Path {
35
36
path
36
37
}
37
38
39
+ fn strip_file_scheme ( input : & str ) -> Cow < ' _ , str > {
40
+ if input. starts_with ( "file://" ) {
41
+ Cow :: Owned ( input. strip_prefix ( "file://" ) . unwrap ( ) . to_owned ( ) )
42
+ } else {
43
+ Cow :: Borrowed ( input)
44
+ }
45
+ }
46
+
38
47
async fn create_module_path (
39
48
global_specifier : & str ,
40
49
entry_path : & Path ,
41
50
output_folder : & Path ,
42
51
) -> PathBuf {
52
+ let cleaned_specifier = strip_file_scheme ( global_specifier) ;
43
53
let cleaned_specifier =
44
- global_specifier . replace ( entry_path. to_str ( ) . unwrap ( ) , "" ) ;
54
+ cleaned_specifier . replace ( entry_path. to_str ( ) . unwrap ( ) , "" ) ;
45
55
let module_path = PathBuf :: from ( cleaned_specifier) ;
46
56
47
57
if let Some ( parent) = module_path. parent ( ) {
@@ -70,7 +80,7 @@ async fn extract_modules(
70
80
lowest_path : & str ,
71
81
output_folder : & Path ,
72
82
) {
73
- let main_path = PathBuf :: from ( lowest_path) ;
83
+ let main_path = PathBuf :: from ( & * strip_file_scheme ( lowest_path) ) ;
74
84
let entry_path = main_path. parent ( ) . unwrap ( ) ;
75
85
for global_specifier in specifiers {
76
86
let module_path =
You can’t perform that action at this time.
0 commit comments